public class hh {
public static void main(String[]args)
{
ilike like=(a,b)->{
System.out.println("ad"+(a+b));
return a+b;
};
like.lambda(100, 200);
//一行代码省略格式
ilike like2=(a,b)->a+b;//return 也省略掉
like2.lambda(200, 200);
ilike like3=(a,b)->100;//相当于返回值就是100
like3.lambda(300, 200);
}
}
interface ilike{
int lambda(int a,int b);
}
class like implements ilike{
public int lambda(int a,int b)
{
System.out.println("ad"+(a+b));
return a+b;
}
}
原文地址:https://blog.51cto.com/14437184/2427437
时间: 2024-10-17 09:56:14