userList = userList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()->new TreeSet<>(Comparator.comparing(User::getCity))), ArrayList::new));
User::getCity 对象要去重的这段,这里表示根据城市属性进行去重
userList = userList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()->new TreeSet<>(Comparator.comparing(User::getCity))), ArrayList::new));
User::getCity 对象要去重的这段,这里表示根据城市属性进行去重