JDK8 List根据某一字段筛选重复数据

String codes = lineVOList.stream().filter(ro->!ObjectUtils.isEmpty(ro.getCode()))
                .collect(Collectors.groupingBy(lineVO::getCode,Collectors.counting()))
                .entrySet().stream().filter(e->e.getValue()>1).map(Map.Entry::getKey).collect(Collectors.joining(","));

 

posted @ 2022-04-12 15:36  哎丫丫呀喂  阅读(679)  评论(0编辑  收藏  举报