Saturday 16 March 2013

What is the difference between Iterator and Enumeration?

What is the difference between Iterator and Enumeration? 
Enumeration and Iterator both are interfaces present in util package. Enumeration is a legacy interface which does not come under the collection framework, wheras Iterator is an interface present in the collection framework. All the legacy classes like Stack, Vector , Hashtable, Properties can use Enumeration for enumerating the elements from the collection. The classes under the collection framework like ArrayList, LinkedList, HashSet ,Tree Set etc can use the Iterator interface.

Iterator actually adds one method that Enumeration doesn't has: remove().



Blog Author: Vijay Kumar

Go to: Coding Problem Solutions

No comments: