Monday, 16 January 2017

HashSet : IsEmptyMethod





import java.util.HashSet;

public class IsEmptyMethod {

    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);
       
        System.out.println("Check List is Empty or not [ True = Empty && False = Not-Empty ]  : "+ss1.isEmpty());
       
    }
}

No comments:

Post a Comment