2
  • I have been thinking about very much, Why ListIterator for List and Set is not. Can someone explain to me ? Thanks
Quan Nguyen
  • 698
  • 1
  • 9
  • 19

1 Answers1

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