这是我尝试过的。它甚至不编译。
public class LambdaExample {
public static Integer handleOperation(Integer x, Integer y, Function converter){
return converter.apply(x,y);
}
public static void main(String[] args){
handleOperation(10,10, Operation::add);
}
}
class Operation {
public int add(Integer x, Integer y){
return x+y;
}
}
我想在这里实现/学习的几件事是:
1)如何lambda expression
作为方法参数传递(在上面的main
方法中)
2)如何给函数传参( handleOpertion
方法中,compilation
apply只带一个参数的错误)