java多线程-lambda带返回值
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;
}
}
网站标题:java多线程-lambda带返回值
本文来源:http://ybzwz.com/article/pesdjc.html