/*
推导lambda表达式
*/publicclassTestLambadal{//3.静态内部类staticclassLike2implementsILike{@Overridepublicvoidlambda(){
System.out.println("I like lambda1");}}publicstaticvoidmain(String[] args){
ILike like =newLike();
like.lambda();
like =newLike2();
like.lambda();//4.局部内部类classLike3implementsILike{@Overridepublicvoidlambda(){
System.out.println("I like lambda3");}}
like =newLike3();
like.lambda();//5.匿名内部类,没有类的名称,必须借助接口或者父类
like =newILike(){@Overridepublicvoidlambda(){
System.out.println("I like lambda4");}};
like.lambda();//6.用lambda简化
like =()->{
System.out.println("I like lambda6");};
like.lambda();
like =()-> System.out.println("I like lambda6");
like.lambda();//lambda表达式只能有一行代码的情况下才能简化为一行,如果有多行,那么就用代码包裹。//前提是接口为函数式接口//多个参数也可以去掉参数类型,要去掉就都去掉,必须加上括号}}//1.定义一个函数式接口interfaceILike{voidlambda();}//2.实现类classLikeimplementsILike{@Overridepublicvoidlambda(){
System.out.println("I like lambda");}}