package lambda; import java.util.function.Consumer; import org.junit.Test; public class TestLambda2 { @Test public void test1() { /** * 匿名内部类 */ Runnable ra=new Runnable() { @Override public void run() { // TODO Auto-generated method stub System.out.println("测试111111111111111"); } }; ra.run(); /** * lambda表达式 */ Runnable r1=() ->System.out.println("测试2222222222222"); r1.run(); } /** * */ @Test public void test3() { Consumer<String>con=(x)->System.out.println(x); con.accept("我在测试》》》》》》》》》》》》》》"); } }