September 2019
Intermediate to advanced
816 pages
18h 47m
English
Partitioning is a type of grouping that relies on a Predicate to divide a stream into two groups (a group for true and a group for false). The group for true stores the elements of the stream that have passed the predicate, while the group of false stores the rest of the elements (the elements that fail the predicate).
This Predicate represents the classification function of partitioning and is known as the partitioning function. Since the Predicate is evaluated to a boolean value, the partitioning operation returns a Map<Boolean, V>.
Let's assume that we have the following Melon class and List of Melon:
public class Melon { private final String type; private int weight; // constructors, getters, setters, equals(), // hashCode(), ...