StackOverflow 文档 Kotlin 教程 Java 8 Stream 等价物 计算员工工资总额 计算员工工资总额 Created: November-22, 2018 placeholderCopy// Java: int total = employees.stream() .collect(Collectors.summingInt(Employee::getSalary))); placeholderCopy// Kotlin: val total = employees.sumBy { it.salary } 按部门分组员工将元素转换为字符串并用逗号分隔它们