View Single Post
  #6 (permalink)  
Old 08-05-2007, 02:47 AM
henry_78 henry_78 is offline
Member
 
Join Date: Aug 2007
Posts: 47
henry_78 is on a distinguished road
If u do like that, u wont even know when u reach the end of the collection.
When a n iterator reach the end of a collection it stops..it dosen't go back to the first element.
U should change only the next() method like that:

public AnotherClass next() {
if(count == collection.size() ){
throw new NoSuchElementException();
}
count++;
return collection[count];
}
Reply With Quote