public static ArrayList getSingle(ArrayList list) {
ArrayList newList = new ArrayList<>();
Iterator it = list.iterator();
while(it.hasNext()) {
Object obj = it.next();
if(!newList.contains(obj)) {
newList.add(obj);
}
}
return newList;
}
为什么要将it.next()对象存入obj中,是否可以直接contains(it.nextI())?
|
|