Answer the question
In order to leave comments, you need to log in
Why doesn't the listIterator interface fire a second time?
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add("First");
arrayList.add("Second");
arrayList.add("Third");
arrayList.add("Fourth");
arrayList.add("Fifth");
arrayList.add("Sixth");
ListIterator<String> listIterator = arrayList.listIterator();
while (listIterator.hasNext()){
System.out.println(listIterator.next());
}
System.out.println("-------");
while (listIterator.hasNext()){
System.out.println(listIterator.nextIndex());
listIterator.next();
}
Answer the question
In order to leave comments, you need to log in
Because iterators remember their state, and you can't enter this water a second time - you need to take the iterator again!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question