View Single Post
  #5 (permalink)  
Old 08-05-2007, 01:58 AM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
Seems like you would reset the count after the last element was sent out.
Code:
public AnotherClass next() { if(count == collection.size()){ throw new NoSuchElementException(); } if(count == collection.size()-1) { // last element being sent out. count = 0; return collection[collection.size()-1]; } return collection[count]; }
Reply With Quote