Lesson 20: Stream API
Yakov Fain · 2015
This chapter explains how to work with the new Stream application programming interface (API) introduced in Java 8. Stream API enables you to write data processing in a simpler and more understandable way. Most of the examples in the chapter illustrate iterating and manipulating data from Java collections. The chapter uses a collection of beers to make working with stream API more fun. There are two types of operations that you can apply to a stream: intermediate and terminal. The whole idea of using intermediate operations is to express your intentions in a declarative form. The chapter further explains the terms filter, map, and reduce. It then looks at the proof that intermediate operations don't access the data. The method Stream.generate() can take a lambda expression that generates values by some arbitrary algorithm.