In the Java Lambda API, the main class is java.util.function.Function .
You can use the link to this interface in the same way as with all other links: create it as a variable, return it as a result of calculations, etc.
Here is a pretty simple example that might help you:
public class HigherOrder { public static void main(String[] args) { Function<Integer, Long> addOne = add(1L); System.out.println(addOne.apply(1));
If you need to pass more than 1 parameter, check out the compose method, but using it is quite difficult.
In general, in my opinion, closure and lambda in Java are basically sugar syntax, and they don't seem to have all the features of functional programming.
n1ckolas
source share