I have a function in class ABC whose definition is roughly as below
Boolean getBool(Value val1, Value val2) {
if (val1.getVal() == val2.getVal()) {
return true;
}
return false;
}
How can I pass this method as reference to another method, let's say operate() and call it from there.
String operate(<<<Pass getBool method here>>>, Param1) {
val1 = some computations on Param1
val2 = some other computations on Param2
Boolean value = <<<<<Call getBool with val1 and val2 here>>>>>
if (value) { return "Yes"; }
else { return "No"; }
}
Please help!! I have read a couple of solutions but they are either passing a method by reference with parameters, but void return type, or, passing a method by reference without any parameters and some return type. I want to pass a function by reference with parameters and having some return type.