public static void main(String[] args) {List<Driver> drivers = new ArrayList<Driver>();Driver driver1 = new Driver();driver1.setName(张三);drivers.add(driver1);Driver driver2 = new Driver();driver2.setName(张三);drivers.add(driver1);List<Driver> bDrivers = removeRepeatDriver(drivers);for (Driver driver : bDrivers) {System.out.println(driver.getName());}} public static List<Driver> removeRepeatDriver(List<Driver> aDrivers){ Set<Driver> set = new TreeSet<Driver>(new Comparator<Driver>() { [@Override](https://my.oschina.net/u/1162528) public int compare(Driver o1, Driver o2) { //字符串,按照asicc码排序 return o1.getName().compareTo(o2.getName()); } }); set.addAll(aDrivers); return new ArrayList<Driver>(set);}