isEmpty(): This method is available in java.util.TreeSet class of Java.
Syntax:
boolean java.util.TreeSet.isEmpty()
This method returns true if this set contains no elements.
Parameters: NA
Returns: true if this set contains no elements.
Exceptions: NA
Approach
Java
import java.util.TreeSet;public class TreeSetisEmpty {public static void main(String[] args) {TreeSet<String> treeSet = new TreeSet<String>();treeSet.add("Hello");treeSet.add("Java");treeSet.add("Program");treeSet.add("C++");System.out.println(treeSet.isEmpty());}}
Output:
false
No comments:
Post a Comment