方法一:
// 去除重复的pGroupId并保持顺序不变
List<Long> groupList = new ArrayList<Long>();
for (Long a : list) {
if (!groupList.contains(a)) {
groupList.add(a);
}
// 去除重复的pGroupId并保持顺序不变
List<Long> groupList = new ArrayList<Long>();
for (Long a : list) {
if (!groupList.contains(a)) {
groupList.add(a);
}
}
方法二:
//去除重复保存到hashset集合中,顺序是变化的
//list为要去重的集合
//hs为去重后的集合
HashSet<Long> hs=new HashSet<Long>(list);