In this chapter, we used the different versions of the
collect() method provided by the
Stream framework to transform and group the elements of a
Stream. This and Chapter 7, Processing Massive Datasets with Parallel Streams – The Map and Reduce Model, teach you how to work with the whole stream API.
collect() method needs a collector that processes the data of the stream and generates a data structure returned by the set of aggregate operations that forms the stream. A collector works with three different data structures—the class of the input elements, an intermediate data structure used while processing the input elements, and a final data structure that is returned.
We used the different versions of the
collect() method ...