February 2014
Beginner
1248 pages
62h 25m
English
Lines 24–27 of Fig. 17.6 create a Stream<Integer>, call Stream method filter (which receives a Predicate) to locate all the values greater than 4 and collect the results into a List<Integer>. Like IntPredicate (Section 17.3.4), functional interface Predicate has a test method that returns a boolean indicating whether the argument satisfies a condition, as well as methods and, negate and or.
We assign the stream pipeline’s resulting List<Integer> to variable greaterThan4, which is used in line 28 to display the values greater than 4 and used again in lines 40–42 to perform additional operations on only the values greater than 4.
Read now
Unlock full access