image

CHAPTER4

Ending Streams: Collection and Reduction

Pipelines are ended by terminal operations, which we saw in Chapter 3 are divided into three groups: search operations, reductions, and operations with side-effects. Although we surveyed all three groups then, there is much more to say about reductions; this chapter takes up that story.

Broadly speaking, reductions are operations which return a single value that in some way summarizes the values of the stream elements. But this description does not make a distinction—very important to Java programmers—between summarizing operations that create new objects and those that change their operands. Traditional ...

Get Mastering Lambdas now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.