import java.util.HashSet;
public class Hash
{
public static void main(String args[])
{
HashSet<String> h1 = new HashSet<String>();
h1.add("jabalpur");
h1.add("nagpur");
h1.add("jabalpur");
h1.add("delhi");
h1.add("indore");
System.out.println(h1);
//find data item
System.out.println(h1.contains("indore"));
//remove data element
h1.remove("delhi");
System.out.println(h1);
//display the size of hashset
System.out.println(h1.size());
//clear all data item
h1.clear();
System.out.println(h1);
}
}
Comments
Post a Comment