Here is what I tried. and it does not even compile.
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;
}
}
Couple of things I am trying to acheive/learn here is:
1) how to pass lambda expression
as method parameter ( in main
method above)
2) how to pass parameters to the function (in handleOpertion
method, there is compilation
error that apply takes only one parameter)