...
/Collectors: Aggregation Operations
Collectors: Aggregation Operations
In this lesson, we will learn about methods of the Collectors class, which are used for aggregation.
We'll cover the following...
We'll cover the following...
In this lesson, we will look at some of the methods of the Collectors class that help us aggregate the data in streams, e.g., sum, average, etc.
1) counting()
This function returns a Collector that counts the number of the input elements.
Suppose we have a list of employees, and we need the count of employees with an age more than 30.
In this case, we can use the counting() method as shown below.
2) Collectors.summingInt(ToIntFunction<? super T> mapper)
This method returns a ...