}
public static ArrayList<String> getSingle(ArrayList list){
ArrayList<String> newlist = new ArrayList<>();
Iterator<String> it = list.iterator();
while(it.hasNext()){
if(!newlist.contains(it.next()));
newlist.add(it.next());
}
return newlist;
}
报错:Exception in thread "main" java.util.NoSuchElementException
at java.util.ArrayList$Itr.next(ArrayList.java:834)
at com.aaa.demo.demo1_去除集合中重复元素.getSingle(demo1_去除集合中重复元素.java:31)
at com.aaa.demo.demo1_去除集合中重复元素.main(demo1_去除集合中重复元素.java:22)