Skip to content

Commit 201c596

Browse files
committed
Add SumSalaryDeptWiseQ17 class to calculate total salary by department
1 parent f59bd36 commit 201c596

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 SumSalaryDeptWiseQ17 {
8+
public static void main(String[] args) {
9+
List<Employee> employees = EmployeeDTO.getEmployees();
10+
Map<String, Double> sumMap = employees.stream().collect(Collectors.groupingBy(
11+
Employee::getDepartment,Collectors.summingDouble(Employee::getSalary)));
12+
System.out.println(sumMap);
13+
}
14+
}

0 commit comments

Comments
 (0)