【发布时间】:2018-01-17 02:00:51
【问题描述】:
public class FetchVarableList {
public static void main(String[] args) {
Employee e1 = new Employee(1, "Abi", "Fin", 2000);
Employee e2 = new Employee(2, "Chandu", "OPs", 5000);
Employee e3 = new Employee(3, "mahesh", "HR", 8000);
Employee e4 = new Employee(4, "Suresh", "Main", 1000);
List<Employee> empList = new ArrayList<>();
empList.add(e1); empList.add(e2); empList.add(e3); empList.add(e4);
List<String> emps = empList.stream().map(p -> p.getEmpName())
.collect(Collectors.toList());
emps.forEach(System.out::println);
}
}
这关于编程工作正常,但我有一个声纳违规, 如何更改为 lambda 表达式?我需要一些帮助
【问题讨论】:
-
.map(Employee::getEmpName)
-
谢谢,它正在工作