StackOverflow 文档 Kotlin 教程 Java 8 Stream 等价物 按部门分组员工 按部门分组员工 Created: November-22, 2018 // Java: Map<Department, List<Employee>> byDept = employees.stream() .collect(Collectors.groupingBy(Employee::getDepartment)); // Kotlin: val byDept = employees.groupBy { it.department } 按部门计算工资总额计算员工工资总额