O'Reilly logo

Learning Java Functional Programming by Richard M Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the Stream class methods

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.

Filter methods

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required