Differences Between Enumeration And Iterator In Java
1) Introduction Iterator interface is introduced from JDK 1.2 where as Enumeration interface is there from JDK 1.0. 2) remove() method This is the main difference between Enumeration and Iterator interface. Enumeration only traverses the Collection object. You can’t do any modifications to Collection while traversing the Collection using Enumeration . Where as Iterator interface allows us to remove an element while traversing the Collection object. Iterator has remove() method which is not there in the Enumeration interface. Below is the list of Enumeration and Iterator methods. Iterator Enumeration hasNext() hasMoreElements() next() nextElement() remove() (Not Available) 3) Legacy Interface Enumeration is a legacy interface used to traverse only the legacy classes like Vect...