public static ArrayList<Room> removeDuplicate(List<Room> room) { Set<Room> set = new TreeSet<Room>(new Comparator<Room>() { @Override public int compare(Room o1, Room o2) { //字符串,则按照asicc码升序排列 return o1.getId().compareTo(o2.getId()); } }); set.addAll(room); return new ArrayList<Room>(set); }