标签:dal set hashset dup element turn for 去重 add
public <T> List<T> removeDuplicateKeepOrder(List<T> list){
Set set = new HashSet();
List<T> newList = new ArrayList<T>();
for (T element : list) {
if (set.add(element)) newList.add(element);
}
list.clear();
list.addAll(newList);
return list;
}
标签:dal set hashset dup element turn for 去重 add
原文地址:https://www.cnblogs.com/jjSmileEveryDay/p/9671375.html