Chapter 4. Streams and the Evaluation of Expressions
In this chapter, we will examine how Java 8 supports the concept of streams. A stream can be thought of as a sequence of elements processed by a series of methods using a fluent interface. The stream concept is supported by the Stream
class.
We will begin with a brief overview of the Stream
class and its methods. After conveying the essence of the stream technique, we will examine how streams are created and show how they can replace imperative and object-oriented approaches to solve similar problems. The intent is to provide an overview of the Stream
class and its methods. A detailed coverage of each method is not possible here.
The topics you will cover include the following:
- Creating fixed and infinite length streams
- Filtering a stream
- Sorting streams
- Mapping elements of a stream
How stream methods are evaluated is also of interest—either in a lazy or eager manner. How they are evaluated affects when their methods are executed...