Java常用lambda表达式

1.提取某一列

//从对象列表中提取一列(以name为例)

List nameList = studentList.stream().map(StudentInfo::getName).collect(Collectors.toList());

2.过滤

List<Apple> filterList = appleList.stream().filter(a -> a.getName().equals("香蕉")).collect(Collectors.toList());

posted @ 2022-05-09 14:10  jiafeng  阅读(68)  评论(0编辑  收藏  举报