lambda操作arrayList

//多个集合合并,得到一个新的集合
 List<T> list= Stream.of(list1, list2, ...).flatMap(Collection::stream).collect(Collectors.toList());

  

//集合根据某一属性去重,得到一个新的集合
List<T> newList = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->new TreeSet<>(Comparator.comparing(T::属性))), ArrayList::new));

  

//获取一个集合中,某个对象指定属性的集合
List<Integer> msisdnList =list.stream().map(T::指定属性).collect(Collectors.toList());

  

posted @ 2023-03-21 10:49  青竹玉简  阅读(31)  评论(0编辑  收藏  举报