首页 > 其他 > 详细

Lambda表达式使用整理

时间:2020-03-24 19:18:21      阅读:60      评论:0      收藏:0      [点我收藏+]

1、List转换

List<String> departmentIdList = userList.stream().map(e -> e.getDepartmentId()).collect(Collectors.toList());

2、List转换并且转换为Set

Set<String> departmentIdSet = userList.stream().map(e -> e.getDepartmentId()).filter(e -> ValidateUtil.isNotNull(e)).collect(Collectors.toSet());

3、过滤

Set<String> departmentIdSet = userList.stream().map(e -> e.getDepartmentId()).filter(e -> ValidateUtil.isNotNull(e)).collect(Collectors.toSet());

4、List转换为Map

Map<String, String> deptMap = userDeptList.stream().collect(Collectors.toMap(e -> e.getDeptId(), e -> e.getDeptName()));

 

Lambda表达式使用整理

原文:https://www.cnblogs.com/dancser/p/12560927.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!