List集合根据某个字段去重

287 阅读1分钟
list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()
        ->new TreeSet<>(Comparator.comparing(User::getId))), ArrayList::new));