Java Reference
In-Depth Information
Figure 3.4. Deconstructing the type-checking process of a lambda
expression
List<Apple> heavierThan150g =
filter(inventory, (Apple a) -> a.getWeight() > 150 );
The type-checking process is deconstructed as follows:
First, you look up the declaration of the filter method.
Second, it expects as the second formal parameter an object of type Predicate-<Apple> (the target
type).
Third, Predicate<Apple> is a functional interface defining a single abstract method called test .
Fourth, the method test describes a function descriptor that accepts an Apple and returns a
boolean .
 
Search WWH ::




Custom Search