List of usage examples for java.util HashSet HashSet
public HashSet()
From source file:Main.java
public static void main(String args[]) { HashSet<String> hs = new HashSet<String>(); System.out.println(hs.isEmpty()); }
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<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> newset = new HashSet<String>(); // populate hash set newset.add("Learning"); newset.add("from"); newset.add("java2s.com"); System.out.println("Size of the set: " + newset.size()); }
From source file:Main.java
public static void main(String args[]) { HashSet<String> newset = new HashSet<String>(); // populate hash set newset.add("Learning"); newset.add("from"); newset.add("java2s.com"); // checking elements in hash set System.out.println("Hash set values: " + newset); }
From source file:HashSetDemo.java
public static void main(String args[]) { HashSet<String> hs = new HashSet<String>(); hs.add("B");/*from w w w .j a v a 2s . c o m*/ hs.add("A"); 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<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);// w ww . j av a 2 s. c o m }
From source file:Main.java
public static void main(String args[]) { HashSet<String> newset = new HashSet<String>(); // populate hash set newset.add("Learning"); newset.add("from"); newset.add("java2s.com"); // check the existence of element boolean exist = newset.contains("Simply"); System.out.println("Is the element 'Simply' exists: " + exist); }
From source file:Main.java
public static void main(String args[]) { HashSet<String> newset = new HashSet<String>(); // populate hash set newset.add("Learning"); newset.add("from"); newset.add("java2s.com"); // check if the has set is empty boolean isempty = newset.isEmpty(); System.out.println("Is the hash set empty: " + isempty); }
From source file:Main.java
public static void main(String args[]) { Set set = new HashSet(); Set set2 = new HashSet(); StringBuffer buff1 = new StringBuffer("Irish Setter"); StringBuffer buff2 = new StringBuffer("Irish Setter"); set.add(buff1);/*from www . jav a 2 s . c om*/ set2.add(buff2); System.out.println(set.addAll(set2)); System.out.println(set.addAll(set)); }