Stream根据多个字段去重

List<ClassEntity> distinctClass =
classEntities.stream().collect
(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getProfessionId() + ";" + o.getGrade()))), ArrayList::new));
posted @ 2020-09-25 13:43  w'c's  阅读(4385)  评论(1编辑  收藏  举报