Working with Streams
In this chapter you will learn about the Stream API, a new feature of JDK 8. To understand the topics in this chapter, you need to know how to use Lambda expressions and the predefined functional interfaces in java.util.function, both discussed in Chapter 19, “Lambda Expressions.”
A stream is like a pipe, but instead of transporting water or oil, a stream transfers data from a source to a destination. Depending on the mode of transfer, a stream can be either sequential or parallel. A parallel stream is especially useful if the computer the program is running on has a multicore CPU.
At first glance, a stream may look like a collection. However, a stream is not a data structure for storing objects, ...