3 ms·
You need an helper method for that public class Main { private static <T,R> Function<T,R> fun(Function<T,R> function) { return function;
by _old_dude_ 3y ago
You need an helper method for that
public class Main {
private static <T,R> Function<T,R> fun(Function<T,R> function) {
return function;
}
public static void main(String[] args) {
var add = fun(x -> fun(y -> x + y));
var addFive = add.apply(5);
int result = addFive.apply(3); // Output will be 8
}
}
Those helpers should be part of the JDK.