Sunday, November 25, 2012

HashSet Example program in Collections

import java.util.*;
class TestHashSet
{
    public static void main(String[] args)
    {
        HashSet<String> hs=new HashSet<String>();
        hs.add("Ram");

        hs.clear();
        hs.add("sree");
        hs.add("sri");
        hs.add("Rama");
        hs.remove("Ram");
        //System.out.println(hs.contains("sita"));
    System.out.println(hs.isEmpty());
        System.out.println(hs.size());
                System.out.println
(hs);
    }
}

No comments:

Post a Comment