Example usage for java.util HashSet HashSet

List of usage examples for java.util HashSet HashSet

Introduction

In this page you can find the example usage for java.util HashSet HashSet.

Prototype

public HashSet(int initialCapacity) 

Source Link

Document

Constructs a new, empty set; the backing HashMap instance has the specified initial capacity and default load factor (0.75).

Usage

From source file:Main.java

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

    hs.add("java2s.com");
    hs.add("j a v a2s.com");

    System.out.println(hs);//from  w  w w.j ava2  s.  co  m
}

From source file:Main.java

public static void main(String[] args) {

    HashSet<String> months = new HashSet<String>(24);

    Collections.addAll(months, DateFormatSymbols.getInstance().getMonths());
    Collections.addAll(months, DateFormatSymbols.getInstance().getShortMonths());

    System.out.println(months.contains(args[0]));

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int[] array = new int[10];

    Set set = new HashSet(Arrays.asList(array));
}

From source file:Iterate.java

public static void main(String args[]) {
    String elements[] = { "Irish Setter", "Poodle", "English Setter", "Gordon Setter", "Pug" };
    Set set = new HashSet(Arrays.asList(elements));
    Iterator iter = set.iterator();
    while (iter.hasNext()) {
        System.out.println(iter.next());
    }/*from   w w  w . ja v  a 2 s  . com*/
}

From source file:MainClass.java

public static void main(String[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    Set set = new HashSet(Arrays.asList(elements));

    System.out.println(set.isEmpty());
}

From source file:MainClass.java

public static void main(String[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    Set set = new HashSet(Arrays.asList(elements));

    System.out.println(set.contains("A"));
}

From source file:Main.java

public static void main(String[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    Set<String> set = new HashSet<String>(Arrays.asList(elements));

    System.out.println(set.contains("A"));
}

From source file:MainClass.java

public static void main(String[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    Set set = new HashSet(Arrays.asList(elements));

    System.out.println(set);/* w  w  w . j av a2 s  . c o m*/

}

From source file:Main.java

public static void main(String[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    Set<String> set = new HashSet<String>(Arrays.asList(elements));

    System.out.println(set.size());
}

From source file:Main.java

public static void main(String[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    Set<String> set = new HashSet<String>(Arrays.asList(elements));

    System.out.println(set.isEmpty());
}