HashSet hs = new HashSet();
hs.add("apple");
hs.add("banana");
hs.add("cidar");
hs.add("apple");
System.out.println(hs);
if (hs.contains("strawberry")==true)
System.out.println("It has an apple");
Iterator it = hs.iterator();
while (it.hasNext()) {
Object obj = it.next();
System.out.println(obj);
}
HashSet hs1 = (HashSet) hs.clone();
hs1.add("melon");
hs1.remove("apple");
System.out.println("hs1"+hs1);
System.out.println("hs"+hs);
HashSet hs2 = (HashSet) hs.clone();
hs2.addAll(hs1);
System.out.println(hs2);
hs2.retainAll(hs);
System.out.println(hs2);
}
}