The isEmpty() method 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 list_name 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 ArrayList is empty The ArrayList is not empty
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- ArrayList in Java
- Stack Class in Java
- HashSet vs TreeSet in Java
- ShortBuffer allocate() method in Java With Examples
- IntBuffer duplicate() method in Java with Examples
- ShortBuffer compact() method in Java With Examples
- LongBuffer equals() method in Java
- IntBuffer array() method in Java
- IntBuffer hasArray() method in Java
- ShortBuffer arrayOffset() method in Java With Examples