/* hashset in java example, hashset in java example program */
HashSet is a collection. You can not store duplicate value in HashSet.
HashSet is a collection. You can not store duplicate value in HashSet.
import java.util.HashSet;
public class HashSetDemo
{
public static void main(String[] arg)
{
java.util.HashSet hs = new java.util.HashSet();
hs.add("Bharat");
hs.add("Gyan");
hs.add("Ankita");
hs.add("Sathya");
System.out.println("All data of HashSet : "+hs);
{
public static void main(String[] arg)
{
java.util.HashSet hs = new java.util.HashSet();
hs.add("Bharat");
hs.add("Gyan");
hs.add("Ankita");
hs.add("Sathya");
System.out.println("All data of HashSet : "+hs);
}
}
Output :
All data of HashSet : [Gyan,Ankita,Sathya,Bharat]
}
Output :
All data of HashSet : [Gyan,Ankita,Sathya,Bharat]
0 comments:
Post a Comment