188. Summarization collectors

Let's assume that we have the well-known Melon class (that uses type and weight) and List of Melon:

List<Melon> melons = Arrays.asList(new Melon("Crenshaw", 2000),
new Melon("Hemi", 1600), new Melon("Gac", 3000),
new Melon("Apollo", 2000), new Melon("Horned", 1700),
new Melon("Gac", 3000), new Melon("Cantaloupe", 2600));

The Java Stream API groups the count, sum, min, average, and max operations under the term summarization. The methods dedicated to performing summarization operations are found in the Collectors class.

We'll take a look at all of these operations in the following sections.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.170.187