Could someone give me an example of the best way to add an iterator to a custom class pre Java 5's iterable interface?
Would wrapping a Collection be the best option? Something like
public Iterator iterator() {
return wrappedCollection.iterator();
}
In my initial post I confused Iterator with Iterable. The end result I am interested in is being able to operate on the custom class with the following.
Iterator it = customClass.iterator();
while (it.hasNext()) {
//do stuff
}