去重集合List<<Map<String, Object>>
public static List<Map<String, Object>> duplicateKey(List<Map<String, Object>> list) {
if (ObjectUtil.isNotEmpty(list)) {
list = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(
() -> new TreeSet<>(Comparator.comparing(itemMap -> itemMap.get("key").toString()))), ArrayList::new));
}
return list;
}
jdk8-》List去重
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Java8处理对象List集合之间的交集、并集、差集和去重
Java8处理对象List集合之间的交集、并集、差集和去重
交集 并集 去重 Stream 差集 -
jdk8 list转Map
函数:Collectors.toMapc使用toMap()函数之后,返回的就是一个Map了,会需要k
toMap listToMap -
JDK8
介绍 随着java的发展,越来越多的企业开始使用java8版本。Java8是自从java5之后最重要的版本,这个版本包含
Java 8 java 函数式接口 lambda表达式 -
JDK8 使用流操作处理List
JDK8使用流操作处理List
List JAVA Stream