<Collection_Reference>.stream().collect(Collectors.groupingBy(<Class_Name>::<Method_to_get_group_by_element>,
Collectors.averagingDouble(<Class_Name>::<Method_to_get_element_to_perform_averaging_on>)));
Example -
Get Dept and it's average Salary
list..stream().collect(Collectors.groupingBy(Employee::getDept,
Collectors.averagingDouble(Employee::getSalary)));
|