Monday, 16 January 2017

HashSet : ClearMethod





import java.util.HashSet;

public class ClearMethod {

    public static void main(String[] args) {
        // TODO Auto-generated method stub


        HashSet<String> ss1 = new HashSet<>();   
        ss1.add("One");
        ss1.add("Two");
        ss1.add("Three");
        ss1.add("Four");
        ss1.add("Two");
        ss1.add("Three");
        ss1.add("Four");
        ss1.add("Five");
               
            System.out.println("Full-List (Duplicate Not Allowed in HashSet) : "+ss1);
           
            ss1.clear();
            System.out.print("After clear method Full-List  : "+ss1);
           
    }
}

No comments:

Post a Comment