The isEmpty() method of ArrayList 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
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- ArrayList of ArrayList in Java
- Java String isEmpty() method with example
- AbstractSequentialList isEmpty() method in Java with Example
- Stack isEmpty() method in Java with Example
- LinkedBlockingDeque isEmpty() method in Java with Example
- AbstractSet isEmpty() method in Java with Example
- Arraylist lastIndexOf() in Java with example
- ArrayList trimToSize() in Java with example
- HashMap Class Methods in Java with Examples | Set 1 (put(), get(), isEmpty() and size())
- IdentityHashMap isEmpty() Method in Java
- HashSet isEmpty() Method in Java
- TreeSet isEmpty() Method in Java
- HashMap isEmpty() Method in Java
- Hashtable isEmpty() Method in Java
- ArrayDeque isEmpty() Method in Java
- BitSet isEmpty() method in Java
- WeakHashMap isEmpty() Method in Java with Examples
- Vector isEmpty() Method in Java
- LinkedTransferQueue isEmpty() method in Java
- ConcurrentHashMap isEmpty() Method in Java
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Akanksha_Rai