|
Answer» Iterators differ from enumerations in three ways:
- Iterators allow the caller to REMOVE elements from the underlying collection during the iteration with its remove() method. You can not add/remove elements from a collection when using enumerator.
- ENUMERATION is AVAILABLE in legacy classes i.e Vector/Stack ETC. whereas Iterator is available in all modern collection classes.
- Another minor difference is that Iterator has improved method NAMES e.g. Enumeration.hasMoreElement() has become Iterator.hasNext(), Enumeration.nextElement() has become Iterator.next() etc.
Iterators differ from enumerations in three ways:
|