// Java: Map<Department, List<Employee>> byDept = employees.stream() .collect(Collectors.groupingBy(Employee::getDepartment));
// Kotlin: val byDept = employees.groupBy { it.department }