利用java8对数组按对象属性去重

ArrayList<DeptEntity> disList = newList.stream().collect(
Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(DeptEntity::getId))), ArrayList::new));
posted @ 2021-11-17 19:39  threadThread  阅读(278)  评论(0)    收藏  举报