I know that whenever a foreach loop is executed, a new iterator is created, used, and then never used again.
My question is regarding implementing an iterator for a custom class. By convention, should an iterator that is created using the code
Iterator<E> it = new myClass.iterator();
be able to be reused - that is, should my custom iterator class support iterating through the elements more than once for some reason, or is it convention that a user implementing the API of an Iterable class knows to create a new iterator if he/she wants to iterate the elements again?
I hope my question is not too vague; I'm trying to be as specific as possible without violating code-sharing rules of the class that I am taking. I'm most interested in learning about the conventional use of iterators. I figure also in most cases, a user will only need a one-time-use iterator, but wanted to get more insight perhaps as to where a reusable iterator might be used, needed, or required. Thanks!