List<UserCar> list1 = new ArrayList();
UserCar userCar = new UserCar();
userCar.setId(1);
userCar.setCarNo("AA");
list1.add(userCar);
UserCar userCar1 = new UserCar();
userCar1.setId(2);
userCar1.setCarNo("AA");
list1.add(userCar1);
Person p1 = new Person(1, "11");
Person p2 = new Person(1, "22");
Person p3 = new Person(2, "11");
List<Person> persons = Arrays.asList(p1, p2, p3);
第一种: 不使用java8
private List<UserCar> removeDupliByRecordId(List<UserCar> userCars) {
Set<UserCar> personSet = new TreeSet<UserCar>((o1, o2) ->o1.getRecordId().compareTo(o2.getRecordId()));
personSet.addAll(userCars);
return new ArrayList<UserCar>(personSet);
}