當前位置:編程學習大全網 - 網站源碼 - jdk1.8中list按對象的多個屬性去重,按對象的某個屬性分組

jdk1.8中list按對象的多個屬性去重,按對象的某個屬性分組

List pdVos = pdVoListList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->new TreeSet<>(Comparator.comparing(o -> o.getPiCode() +";" + o.getDeveloperCode()))), ArrayList::new));// 按多個屬性去重列表

Map<String,List<PdVo>> pdVoMap = pdVos.stream().collect(Collectors.groupingBy(PdVo::getDeveloperCode));// 按某個屬性分組

  • 上一篇:如何下載或者保存網頁中的原圖?
  • 下一篇:源代碼和模板
  • copyright 2024編程學習大全網