Java TreeSet isEmpty() methodThe isEmpty() is a method of TreeSet class. This method is used to check whether the set is empty or not. If the set is empty, it returns true else it returns false. Syntax:Specified by:isEmpty in interface Collection<E> : If the collection contains no elements, it returns true. isEmpty in interface Set<E> : If the set contains no elements, it returns true. Return:It returns true if the set contains no elements else returns false. Example 1Output: TreeSet Empty or not: false TreeSet Empty or not: true Example 2Output: TreeSet 1 Empty or not: false TreeSet 2 Empty or not: false TreeSet 2 Empty or not: true Next TopicJava-treeset-iterator-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India