Wednesday, 18 November 2015

Difference between Enumeration, Iterator and ListIterator


S.No
Enumeration
Iterator
ListIterator
1
It can apply only for legacy classes
It can apply for any collection implemented classes
It can apply for list implemented classes
2
By using elements() method, we can get enumeration object.
By using iterator() method, we can get iterator object
By using listIterator() method, we can get ListIterator object
3
It is a forward cursor
It is a forward cursor
It is a bidirectional cursor
4
It has only read access
It has read as well as remove access
It has read, remove, add, modify access
5
It contains only 2 methods. hasMoreElements(), nextElement()
It contains 3 methods: hasNext(), next(), remove()
It contains 9 methods

No comments:

Post a Comment