lambda表达式各种用法

根据姓名去除list中已包含的该姓名的数据
list = list.stream().filter(one-> !one.getUserInfo().contains(one.getName())).collect(Collectors.toList());
遍历map
map.forEach((k.v)->{
  System.out.println("name:"+k+"value:"+v);
}
根据对象属性去重
 userList.stream().collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(UserParam::getOrgCode)))

 

posted @ 2022-03-18 14:11  老小包的博客  阅读(22)  评论(0编辑  收藏  举报