Skip to content

Commit f59bd36

Browse files
committed
Add CountEmployeeDeptWise class to count employees by department
1 parent 1f43e05 commit f59bd36

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.superthirty;
2+
3+
import java.util.List;
4+
import java.util.Map;
5+
import java.util.stream.Collectors;
6+
7+
public class CountEmployeeDeptWise {
8+
public static void main(String[] args) {
9+
List<Employee> employees = EmployeeDTO.getEmployees();
10+
Map<String, Long> countMap = employees.stream()
11+
.collect(Collectors.groupingBy(Employee::getDepartment, Collectors.counting()));
12+
System.out.println(countMap);
13+
}
14+
}

0 commit comments

Comments
 (0)