Difference between Enumeration, Iterator and ListIterator

EnumerationIteratorListIterator
Where we can apply– We can apply it on legacy classes only– We ca apply it on any collection class– We can apply it on list objects only
Is it legacy– Yes version 1.0-No version 1.2– No version 1.2
MovemenetSingle directionSingle directionBi-direction
Allowed OperatorOnly readRead & RemoveRead, Remove, Replace, Add
How to get itby using enumeration() methodBy using iterator() method of Collection InterfaceBy using listIterator() method of List interface
MethodshasNextElement()
nextElement()
hasNext()
next()
remove()
hasNext()
next()
nextIndex()
hasPrevious()
pervious()
previousIndex()
add(Object 0)
remove()
replace(Object 0)

Leave a Comment