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

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Utility Classes » Set 
8.16.2.An Iterator from HashSet presents elements in an unpredictable random order.
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
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.