An Iterator from HashSet presents elements in an unpredictable random order. : Set « Utility Classes « SCJP






import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class MainClass {
  public static void main(String[] argv) {
    Set set = new HashSet();
    set.add("1");
    set.add("2");
    set.add("3");

    Iterator it = set.iterator();
    while (it.hasNext()) {
      System.out.println(it.next());
    }

  }
}
3
2
1








8.16.Set
8.16.1.Sets may not contain duplicate elements.
8.16.2.An Iterator from HashSet presents elements in an unpredictable random order.
8.16.3.Sets differ from lists in that they are unordered and cannot contain duplicates of the same element.
8.16.4.Using Sets