user8706150 user8706150 - 3 years ago 139
Java Question

Iterator vs List

What is the difference between list and iterator and enumeration in java?
Apart from below,

  1. List is a an array with some added advantage.

  2. Iterator is used to traverse through collection object.

  3. Enumeration is the old version of iterator with less methods(functions).

Answer Source

Enumerator cannot modify the collection it is working on. Whereas an Iterator can. Also iterator is fail fast and enumerator is fail safe meaning if another thread modifies the collection the iterator is working on it will throw exception whereas an enumerator will not. These are the kind of fundamental differences between the two. Both have a similiar purpose but have different features and properties build on. Both of these are different from List where List is the actual data structure which holds the data vs Iterator and Enumerator which are interfaces that allow access to work on the underlying collection.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download