list中根据某个字段去除重复值

ArrayList<ENTITY> newList = list.stream().collect
(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(
Comparator.comparing(ENTITY::getId))), ArrayList::new));
————————————————

posted @ 2021-03-13 15:28  才没有木头  阅读(271)  评论(0)    收藏  举报