|
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];
}
|