16
Streams: Advanced Concepts
In Chapter 15, we learned about the fundamentals of streams. We started by discussing what a stream pipeline is by using an analogy of an assembly line. We saw that items only make their way onto the assembly line as and when needed. This is the principle of lazy evaluation. In this analogy, there are several operators that operate on the data (pencils) under the supervision of a supervisor (Java). The supervisor will not allow any work to start until the terminal operation in place. As Java is now aware of the full pipeline, efficiencies can be introduced. Once a pencil has passed an operator, the operator cannot get that pencil back. Thus, streams are different to arrays or Collections in that manner. The pencils ...
Get Learn Java with Projects 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.