Edit: Thank you for all your prompt replies. Now I see the assignment won\'t work. From another thread I read that iterator in Java is much less powerful than iterator in C+
You shouldn't do:
Iterator bIter = aIter;
Because there is no copy constructor etc in Java; bIter will be a reference to the same underlying iterator.
You could use a ListIterator this way:
ListIterator aItr = aList.listIterator();
while (aItr.hasNext()) {
int a = aItr.next();
ListIterator bItr = aList.listIterator(aItr.previousIndex());
while (bItr.hasNext()) {
// ...
}
}
But If you are thinking that ListIterator should have had a copy() method or something along those lines, I agree with you...