0

How are the iterators of an HashSet ordered?

Suppose I got these:

HashSet<E> set = new HashSet<E>();
Iterator<E> it=set.iterator();

Does it.next() return elements in a certain order? And how does it works actually?

Maroun
  • 94,125
  • 30
  • 188
  • 241

1 Answers1

4

From the Javadoc:

Returns an iterator over the elements in this set. The elements are returned in no particular order.

Also, some SO posts:

Community
  • 1
  • 1
Baderous
  • 1,069
  • 1
  • 11
  • 32