The isEmpty() method of List interface in java is used to check if a list is empty or not. It returns true if the list contains no elements otherwise it returns false if the list contains any element.
Parameter: It does not accepts any parameter.
Returns: It returns True if the list has no elements else it returns false. The return type is of datatype boolean.
Error and Exceptions: This method has no error or exceptions.
Program to demonstrate working of isEmpty() in Java:
The List is empty The List is not empty
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.