Skip to Content
Java Projects - Second Edition
book

Java Projects - Second Edition

by Peter Verhas
August 2018
Intermediate to advanced
524 pages
14h 45m
English
Packt Publishing
Content preview from Java Projects - Second Edition

Method references

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> ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java 11 Cookbook - Second Edition

Java 11 Cookbook - Second Edition

Nick Samoylov, Mohamed Sanaulla

Publisher Resources

ISBN: 9781789131895Supplemental Content