This post will discuss different ways to check whether a list is empty in Java. A list is empty if and only if it contains no elements.

1. Using List.isEmpty() method

The recommended approach is to use the List.isEmpty() method to check for an empty list in Java. Following is a simple example demonstrating usage of this method:

 
Instead of explicitly checking if the list is null or empty, you can combine the isEmpty() method with a null check in a single expression, as shown below:

 
Or, even better:

2. Using List.size() method

Finally, you can use the List.size() method, which returns the total number of items in it.

That’s all about checking whether a list is empty in Java.