http://blog.csdn.net/jiaobuchong/article/details/54412094
public List<String> removeStringListDupli(List<String> stringList) { Set<String> set = new LinkedHashSet<>(); set.addAll(stringList); stringList.clear(); stringList.addAll(set); return stringList; }
public List<String> removeStringListDupli(List<String> stringList) {
Set<String> set = new LinkedHashSet<>();
set.addAll(stringList);
stringList.clear();
stringList.addAll(set);
return stringList;
}
或使用Java8的写法:
List<String> unique = list.stream().distinct().collect(Collectors.toList());
可以参见:http://stackoverflow.com/questions/30745048/how-to-remove-duplicate-objects-from-java-arraylist http://blog.csdn.net/growing_tree/article/details/46622579
http://www.cnblogs.com/jizha/p/java_arraylist_duplicate.html
http://stackoverflow.com/questions/29670116/remove-duplicates-from-a-list-of-objects-based-on-property-in-java-8