java8集合的便捷方法
发布时间
阅读量:
阅读量
java8集合的一些简便写法:
2个list集合:listOne listTwo
集合交集:
Create a new list named Names by filtering the items from the stream of listOne, which are present in listTwo, and then converting it to a standard List.
集合差集:
此列表 names 通过从 listOne 中移除 不在 listTwo 中出现的 项目 而被 生成
集合去重:
List list2 = listOne.stream().distinct().collect(Collectors.toList());
根据集合对象的某个字段进行分组:
收集到一个新的带有自定义排序集合的对象distinctList = constructionList.stream()
.collect(Collectors.collectingAndThen(
() -> new TreeSet<>(
Comparator.comparing((Construction c) -> c.getConstruc
全部评论 (0)
还没有任何评论哟~
