List of usage examples for java.util HashSet add
public boolean add(E e)
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 www. ja va 2 s.c o m }
From source file:Main.java
public static void main(String[] args) { HashSet<Integer> hSet = new HashSet<Integer>(); hSet.add(new Integer("1")); hSet.add(new Integer("2")); hSet.add(new Integer("3")); System.out.println(hSet.contains(new Integer("3"))); }
From source file:Main.java
public static void main(String[] args) { HashSet<Long> hashSet = new HashSet<Long>(); hashSet.add(new Long("1111111111")); hashSet.add(new Long("2222222222")); hashSet.add(new Long("3333333333")); hashSet.add(new Long("4444444444")); hashSet.add(new Long("5555555555")); Object obj = Collections.max(hashSet); System.out.println(obj);/*from www . java 2 s .c o m*/ }
From source file:Main.java
public static void main(String[] args) { HashSet<Integer> hSet = new HashSet<Integer>(); hSet.add(new Integer("1")); hSet.add(new Integer("2")); hSet.add(new Integer("3")); System.out.println("HashSet contains.." + hSet); }
From source file:Main.java
public static void main(String args[]) { HashSet<String> hs = new HashSet<String>(20, 0.75F); hs.add("java2s.com"); hs.add("j a v a2s.com"); System.out.println(hs);/*from w w w .j av a 2s . c o m*/ }
From source file:Main.java
public static void main(String[] args) { HashSet<Long> hashSet = new HashSet<Long>(); hashSet.add(new Long("9")); hashSet.add(new Long("4")); hashSet.add(new Long("2")); hashSet.add(new Long("2")); hashSet.add(new Long("3")); Object obj = Collections.min(hashSet); System.out.println("Minimum Element of Java HashSet is : " + obj); }
From source file:HashSetDemo.java
public static void main(String args[]) { HashSet<String> hs = new HashSet<String>(); hs.add("B"); hs.add("A");/*from w w w.j a v a2 s. co m*/ hs.add("D"); hs.add("E"); hs.add("C"); hs.add("F"); System.out.println(hs); }
From source file:Main.java
public static void main(String[] args) { HashSet<Long> hashSet = new HashSet<Long>(); hashSet.add(new Long("9")); hashSet.add(new Long("4")); hashSet.add(new Long("2")); hashSet.add(new Long("2")); hashSet.add(new Long("3")); Object obj = Collections.min(hashSet); System.out.println("Minimum Element of HashSet is : " + obj); }
From source file:Main.java
public static void main(String[] args) { HashSet<Long> hashSet = new HashSet<Long>(); hashSet.add(new Long("1111111111")); hashSet.add(new Long("2222222222")); hashSet.add(new Long("3333333333")); hashSet.add(new Long("4444444444")); hashSet.add(new Long("5555555555")); Object obj = Collections.max(hashSet); //Object obj = Collections.min(hashSet); System.out.println(obj);// www . ja va2 s . c o m }
From source file:Main.java
public static void main(String[] args) { HashSet<Integer> hSet = new HashSet<Integer>(); hSet.add(new Integer("1")); hSet.add(new Integer("2")); hSet.add(new Integer("3")); Object[] objArray = hSet.toArray(); for (Object obj : objArray) System.out.println(obj);/*from w w w.j a v a2 s. c o m*/ }