Arraylist去除重复
//通过遍历老集合,把不包含的obj放到新集合里面去,产生一个新集合,就去重了
publicstaticArrayListgetSingle(ArrayListlist){
ArrayList newArrayList =newArrayList();
Iteratorit = list.iterator();
while(it.hasNext()){
Object obj = it.next();
if(!newArrayList.contains(obj)){
newArrayList.add(obj);
}
}
//产生的新的集合返回出去就是去重了
returnnewArrayList;
}