We would like to know how to create Function lambda and call andThen method.
// w w w . j a va2 s. co m import java.util.function.Function; public class Main { public static void main(String[] args) { Function<Integer, Integer> incrementer = (n) -> n + 1; Function<Integer, Integer> after = (n) -> n - 1; System.out.println(incrementer.andThen(after).apply(2)); } }
The code above generates the following result.