- I have been thinking about very much, Why ListIterator for List and Set is not. Can someone explain to me ? Thanks
Asked
Active
Viewed 1,405 times
2

Quan Nguyen
- 698
- 1
- 9
- 19
1 Answers
4
ListIterator
relies on the elements of the List being ordered (for example, it allows you to add a new element at the current position of the ListIterator). A Set is usually not ordered, so the operations offered by ListIterator make less sense for Sets. A Set still has a regular Iterator (that allows you to iterate over the elements in arbitrary order, unless your Set implementation supports order, as TreeSet and LinkedHashSet do, in which case the iteration will be ordered).

Eran
- 387,369
- 54
- 702
- 768