ArrayList<User> collect = list.stream().collect( Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(User::getId))), ArrayList::new));
java8 实现List根据对象属性去重
最新推荐文章于 2023-08-29 09:26:15 发布
ArrayList<User> collect = list.stream().collect( Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(User::getId))), ArrayList::new));