import org.junit.Test;/** * ClassName: * Function: ADD FUNCTION * Reason: ADD REASON * * @author * @Date * @since Ver 1.1 */public class LambdaTest { @Test public void test1(){ Runnable r2=()-> System.out.println("今天是星期二"); r2.run(); }}--------------------------------------------------------------------
import java.util.Arrays;import java.util.function.Consumer;import java.util.function.Function;/** * ClassName: * Function: ADD FUNCTION * Reason: ADD REASON * * @author * @Date * @since Ver 1.1 */public class LambdaTest2 { public static void main(String[] args) { happyTime(500,(money)-> System.out.println("我花了这么多"+money)); Function<Integer,String[]> function=String[] ::new ; String[] arr=function.apply(10); System.out.println(Arrays.toString(arr)); } public static void happyTime(int money, Consumer<Integer> consumer){ consumer.accept(money); }}
来源:https://www.cnblogs.com/aojie/p/12458494.html