new HashSet < E > () : HashSet « java.util « Java by API






new HashSet < E > ()

 
/**
 *Output: 
[D, A, F, C, B, E]
 */

import java.util.HashSet;

public class MainClass {
  public static void main(String args[]) {
    HashSet<String> hs = new HashSet<String>();

    hs.add("B");
    hs.add("A");
    hs.add("D");
    hs.add("E");
    hs.add("C");
    hs.add("F");

    System.out.println(hs);
  }
}

           
         
  








Related examples in the same category

1.new HashSet(Collection c)
2.HashSet: add(E o)
3.HashSet: addAll(Collection c)
4.HashSet: clear()
5.HashSet: clone()
6.HashSet: contains(Object o)
7.HashSet: containsAll(Collection c)
8.HashSet: isEmpty()
9.HashSet: iterator()
10.HashSet: removeAll(Collection c)
11.HashSet: size()
12.HashSet: toArray()