list 去重并保持原来排序
2021-06-23 21:06
阅读:567
标签:dal set hashset dup element turn for 去重 add list 去重并保持原来排序 标签:dal set hashset dup element turn for 去重 add 原文地址:https://www.cnblogs.com/jjSmileEveryDay/p/9671375.htmlpublic
Set set = new HashSet();
List
for (T element : list) {
if (set.add(element)) newList.add(element);
}
list.clear();
list.addAll(newList);
return list;
}
评论
亲,登录后才可以留言!