VOOZH about

URL: https://www.geeksforgeeks.org/java/list-isempty-method-in-java-with-examples/

⇱ List isEmpty() method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

List isEmpty() method in Java with Examples

Last Updated : 3 Dec, 2024

The isEmpty() method of the 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.

Example:


Output
List is Empty


Syntax of the Method

boolean isEmpty()

  • Parameter : It does not accept any parameter.
  • Return Type : 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 errors or exceptions.

Program Demonstrating List isEmpty() in Java

Below is the implementation of isEmpty() Method:

Comment