The
isEmpty() method of
Java AbstractCollection is used to check and verify if a Collection is empty or not. It returns True if the Collection is empty else it returns False.
Syntax:
AbstractCollection.isEmpty()
Parameters: The method does not take any parameter.
Return Value: The function returns True if the collection is empty else it returns False.
Below program illustrate the use of AbstractCollection.isEmpty() method:
Program 1:
Output:
Collection: [4, Geeks, To, TreeSet, Welcome]
Is the collection empty? false
Is the collection empty? true
Program 2: