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[] argv) throws Exception {
    Set<AWTKeyStroke> set = new HashSet<AWTKeyStroke>(KeyboardFocusManager.getCurrentKeyboardFocusManager()
            .getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));

    set.add(KeyStroke.getKeyStroke("F3"));
    KeyboardFocusManager.getCurrentKeyboardFocusManager()
            .setDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, set);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    Set<AWTKeyStroke> set = new HashSet<AWTKeyStroke>(KeyboardFocusManager.getCurrentKeyboardFocusManager()
            .getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));

    set.add(KeyStroke.getKeyStroke("F2"));
    KeyboardFocusManager.getCurrentKeyboardFocusManager()
            .setDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton component = new JButton("a");

    Set set = new HashSet(component.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));

    set.add(KeyStroke.getKeyStroke("F2"));
    component.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set);

}

From source file:MainClass.java

public static void main(String[] args) {
    List myList = new ArrayList();
    myList.add("Hello");
    myList.add("World");
    myList.add("World");
    Set set = new HashSet(myList);

    System.out.println(set);//from  www.j a  v a  2  s.  c o m
}

From source file:Main.java

public static void main(String args[]) {
    List<String> list = new ArrayList<>();
    list.add("java2s.com");
    list.add("java2s.com");
    list.add("java2s.com");

    HashSet<String> hs = new HashSet<String>(list);

    System.out.println(hs);/*  w  w  w.j  av a  2  s  .  c  o m*/
}

From source file:MainClass.java

public static void main(String args[]) {
    String orig[] = { "I", "P", "E", "G", "P" };
    String act[] = { "P", "P", "S" };
    Set origSet = new HashSet(Arrays.asList(orig));
    List actList = Arrays.asList(act);

    System.out.println(origSet.removeAll(actList));
    System.out.println(origSet);/*from ww  w.j av  a 2s.  c o m*/
}

From source file:Main.java

public static void main(String[] args) {
    List<String> myList = new ArrayList<String>();
    myList.add("Hello");
    myList.add("World");
    myList.add("World");
    Set<String> set = new HashSet<String>(myList);

    System.out.println(set);//  w ww  . j  a v a2s . c  o  m
}

From source file:Main.java

public static void main(String[] args) {
    Integer[] numbers = { 7, 7, 8, 9, 10, 8, 8, 9, 6, 5, 4 };

    List<Integer> list = Arrays.asList(numbers);
    Set<Integer> set = new HashSet<Integer>(list);

    for (Iterator iterator = set.iterator(); iterator.hasNext();) {
        Object o = iterator.next();
        System.out.print(o + ", ");
    }//  ww  w .j  a v a 2s  .  c o m
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton component = new JButton("a");

    Set<AWTKeyStroke> set = new HashSet<AWTKeyStroke>(
            component.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));

    set.add(KeyStroke.getKeyStroke("F2"));
    component.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set);

}

From source file:Main.java

public static void main(String[] args) {
    List<String> myList = new ArrayList<String>();
    myList.add("Hello");
    myList.add(0, "World");
    myList.add("java2s.com");
    Set<String> set = new HashSet<String>(myList);

    System.out.println(set);/* w  ww. ja  va2 s  .com*/
}