流去重

根据单个条件去重
list.stream().collect(
Collectors.collectingAndThen(
Collectors.toCollection(
() -> new TreeSet<>(
Comparator.comparing(Class::getParams)))
, ArrayList::new));

根据多条件去重
list.stream().collect(
Collectors.collectingAndThen(
Collectors.toCollection(
() -> new TreeSet<>(
Comparator.comparing(a->a.getParam1+";"+a.getParam2)))
, ArrayList::new));

流去重

上一篇:hive练习


下一篇:Nginx+keepalived双主架构实战