字符串去重
List<String> dataList = list.stream().distinct().collect(Collectors.toList());
对象属性去重
//根据getName去重
personList = personList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(
() -> new TreeSet<>(Comparator.comparing(Person::getName))), ArrayList::new));
网友评论