STREAM 去重操作

2019-08-23  本文已影响0人  白色普通程序员

List<ClassEntity> distinctClass = classEntities.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getProfessionId() + ";" + o.getGrade()))), ArrayList::new)); 

根据 ProfessionId+ Grade去重

上一篇 下一篇

猜你喜欢

热点阅读