In this recipe, you will learn how to use the local-variable syntax (discussed in the previous recipe) for lambda parameters and the motivation for introducing this feature. It was introduced in Java 11.
Using local-variable syntax for lambda parameters
Getting ready
Until the release of Java 11, there were two ways to declare parameter types—explicit and implicit. Here is an explicit version:
BiFunction<Double, Integer, Double> f = (Double x, Integer y) -> x / y;
System.out.println(f.apply(3., 2)); //prints: 1.5
And the following is an implicit parameter type definition:
BiFunction<Double, Integer, Double> f = (x, y) -> x / y;
System.out.println(f.apply(3., 2)); //prints: 1.5
In the preceding...