In this section, we will explore how the
Stream class methods are used to solve various types of problems. Streams are useful for transforming stream elements, filtering elements, and reducing elements. They can mimic SQL-type processing and implement the map-reduce paradigm, which we will illustrate in the Implementing the map-reduce paradigm section.
The process of filtering involves iterating over a sequence and eliminating those elements that are no longer needed. We will examine how this is accomplished using an imperative loop and then how it is performed using streams.
Assume that we want to filter out the plural names in an animal list. We start with an array of strings containing animal names. ...