ArrayList<Entity> listWithoutDup = list.stream().collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Entity::getId))), ArrayList::new));
用此代码自己写个小demo,试试就知道疗效了.分享给大家
ArrayList<Entity> listWithoutDup = list.stream().collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Entity::getId))), ArrayList::new));
用此代码自己写个小demo,试试就知道疗效了.分享给大家