Is the iteration order of a collection iterator fixed?
Is the iteration order of the iterator the same as the storage order of its collection (List and Set)?
Is the iteration order of a collection iterator fixed?
Is the iteration order of the iterator the same as the storage order of its collection (List and Set)?
List are ordered collections but sets aren't, so both questions are yes in case of lists and no in case of sets. You can view it in java documentation
https://docs.oracle.com/javase/8/docs/api/java/util/List.html
An ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list.
https://docs.oracle.com/javase/8/docs/api/java/util/Set.html
Iterator iterator() Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).