list使用lambda去重

2,191 阅读1分钟
List distinctList = list.stream().collect(
   Collectors.collectingAndThen(
       Collectors.toCollection(
        () -> new TreeSet<>(Comparator.comparing(o ->   o.getAttributeCode()))
       ),
        ArrayList::new
    )
  );