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 } 按部門計算工資總額計算員工工資總額