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
  • 91,013
  • 29
  • 181
  • 233

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,039
  • 1
  • 10
  • 31