August 2018
Intermediate to advanced
524 pages
14h 45m
English
It is lucky that we have Map, which pairs order items with product information, so we can invoke get() on Map:
.map(piMap::get)
The map() method is again something that has the same name as something else in Java, and should not be confused. While the Map class is a data structure, the map() method in the Stream interface performs mapping of the stream elements. The argument of the method is a Function (recall that this is a functional interface that we recently discussed). This function converts a value, T, which is available as the element of the original stream (Stream<T>), to a value, R, and the return value of the map() method is Stream<R>. The map() method converts Stream<T> to Stream<R> using the given Function<T,R> ...