java 对象去重
List<JzInfo> List = jzInfoList.stream()
.collect(Collectors.collectingAndThen(
Collectors.toCollection(() ->
new TreeSet<>(Comparator.comparing(
o -> o.getLac() + ";" + o.getCid()))),
ArrayList::new));
实体类需要重写hashCode() 和 eqauls()
![](https://img.haomeiwen.com/i3710659/c710783b1ceab57e.png)
如此即可
网友评论