In Java 8 and 9, the collections API got a major facelift with the introduction of streams and internal iteration by leveraging lambda expressions. In Java 10 (JDK 18.3), new methods—List.copyOf, Set.copyOf, and Map.copyOf—were added that allow us to create a new immutable collection from existing instances. Also, new methods— toUnmodifiableList, toUnmodifiableSet, and toUnmodifiableMap—were added to the Collectors class in the java.util.stream package, allowing the elements of Stream to be collected into an immutable collection. This chapter shows you how to use the streams and chain multiple operations to create a pipeline. Also, the reader will learn how these operations can be done in parallel. The list of recipes includes the following:
- Create immutable collections using the of() and copyOf() factory methods
- Create and operating...