BeginnersBook
beginnersbook.com › 2013 › 12 › java-arraylist-isempty-method-example
Java ArrayList isEmpty() Method example
The isEmpty() method of java.util.ArrayList class is used to check whether the list is empty or not. This method returns a boolean value. It returns true if the list is empty, and false if the list contains any elements.
Videos
02:31
Java ArrayList isEmpty() Method | ArrayList isEmpty() in Java - ...
02:20
ArrayList isEmpty() in Java with example |How to Check if an ...
Java ArrayList isEmpty() Method
00:54
JAVA UTIL ARRAYLIST ISEMPTY METHOD EXAMPLE DEMO - YouTube
ArrayList isEmpty() in Java with example |How to Check if an ...
W3Resource
w3resource.com › java-tutorial › arraylist › arraylist_isempty.php
Java arraylist isempty Method - w3resource
Java Platform: Java SE 8 · Syntax: isEmpty() Return Value: Returns true if a ArrayList object contains no elements; false otherwise. Return Value Type: boolean · Pictorial presentation of ArrayList.isEmpty() Method · Example: ArrayList.isEmpty ...
W3Schools
w3schools.com › java › ref_arraylist_isempty.asp
Java ArrayList isEmpty() Method
public boolean isEmpty() Java Arrays Tutorial · Java ArrayList Tutorial · ❮ ArrayList Methods · ★ +1 · Sign in to track progress · REMOVE ADS · PLUS · SPACES · GET CERTIFIED · FOR TEACHERS · BOOTCAMPS · CONTACT US · × · If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com ·
GeeksforGeeks
geeksforgeeks.org › java › arraylist-isempty-java-example
ArrayList isEmpty() Method in Java with Examples - GeeksforGeeks
July 11, 2025 - Example 1: Here, we use the isEmpty() method to check whether an ArrayList of integers is empty. ... // Java program to demonstrate the use of isEmpty() // method with ArrayList of Integers import java.util.ArrayList; public class GFG { public static void main(String[] args) { // Creating an empty ArrayList of Integers ArrayList<Integer> n = new ArrayList<>(); // Checking if the ArrayList is empty boolean res = n.isEmpty(); System.out.println("" + res); // Adding an element // to the ArrayList n.add(21); // Checking again if the // ArrayList is empty res = n.isEmpty(); System.out.println("" + res); } }
TutorialsPoint
tutorialspoint.com › home › java/util › java arraylist isempty method
Java ArrayList isEmpty Method
September 1, 2008 - The Java ArrayList isEmpty() method returns true if this list contains no elements. This method always returns the result as per the current state of the list.
Codecademy
codecademy.com › docs › java › arraylist › .isempty()
Java | ArrayList | .isEmpty() | Codecademy
March 10, 2024 - The .isEmpty() function checks if a given ArrayList is empty. It returns true if the ArrayList is empty and false if it is not empty. ... Looking for an introduction to the theory behind programming?
Programiz
programiz.com › java-programming › library › arraylist › isempty
Java ArrayList isEmpty()
import java.util.ArrayList; class Main { public static void main(String[] args) { // create an ArrayList ArrayList<String> languages = new ArrayList<>(); System.out.println("Newly Created ArrayList: " + languages); // checks if the ArrayList has any element boolean result = languages.isEmpty(); // true System.out.println("Is the ArrayList empty?
GeeksforGeeks
geeksforgeeks.org › java › list-isempty-method-in-java-with-examples
List isEmpty() method in Java with Examples - GeeksforGeeks
December 3, 2024 - // Java Program Implementing // List isEmpty() Method import java.util.List; import java.util.ArrayList; public class Main { public static void main(String[] args) { // Creating Empty ArrayList List<Integer> arr = new ArrayList<Integer>(); // Demonstrating isEmpty() Method System.out.print(arr + " : "); System.out.println(arr.isEmpty()); arr.add(1); arr.add(2); arr.add(3); // Demonstrating isEmpty() Method System.out.print(arr + " : "); System.out.println(arr.isEmpty()); } } Output ·
Educative
educative.io › answers › what-is-the-arraylistisempty-method-in-java
What is the ArrayList.isEmpty() method in Java?
The ArrayList.isEmpty() method in Java is used to check if a list is empty. An empty list means that it contains no elements.
Top answer 1 of 5
7
Invert the result of isEmpty().
public boolean notEmpty(ArrayList a) {
return !a.isEmpty();
}
That will tell you when a list is not empty.
2 of 5
1
Alternatively, you can also check whether the array is null by the length/size of the arraylist.
while(arrayListName.size() > 0 ){
//execute code
}
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › ArrayList.html
ArrayList (Java Platform SE 8 )
October 20, 2025 - This class is a member of the Java Collections Framework. ... Constructs an empty list with the specified initial capacity. ... Constructs an empty list with an initial capacity of ten. ... Constructs a list containing the elements of the specified collection, in the order they are returned ...
LabEx
labex.io › tutorials › java-how-to-check-if-a-list-is-empty-in-java-559949
How to Check If a List Is Empty in Java | LabEx
This is a common task in programming, and isEmpty() provides a clear and efficient way to do it. First, let's create a new Java file named ListCheck.java in your ~/project directory. You can do this by right-clicking in the File Explorer on the left and selecting "New File", then typing ListCheck.java. Now, open ListCheck.java in the editor and add the following code: import java.util.ArrayList; import java.util.List; public class ListCheck { public static void main(String[] args) { // Create an empty list List<String> emptyList = new ArrayList<>(); // Create a list with elements List<String> populatedList = new ArrayList<>(); populatedList.add("Apple"); populatedList.add("Banana"); // Check if the lists are empty using isEmpty() System.out.println("Is emptyList empty?
Eduardo Figueiredo
homepages.dcc.ufmg.br › ~andrehora › examples › java.util.ArrayList.isEmpty.11.html
java.util.ArrayList.isEmpty
public class test { public static void main(String[] args) { // Create an empty ArrayList. ArrayList myArrayList = new ArrayList(); // Test whether the array is empty or not. if (myArrayList.isEmpty()) { System.out.println("The ArrayList is empty"); } else { System.out.println("The ArrayList is not empty"); } } }
IncludeHelp
includehelp.com › java › arraylist-isempty-method-with-example.aspx
Java ArrayList isEmpty() Method with Example
public boolean isEmpty(); Parameter(s): It does not accept any parameter. Return value: The return type of this method is boolean, it returns true when this Arraylist is "empty" otherwise it returns false when this Arraylist is "non-empty". Example: // Java program to demonstrate the example ...
W3Docs
w3docs.com › java
Does java.util.List.isEmpty() check if the list itself is null?
Here is an example of how the isEmpty() method can be used: import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] args) { // Create an empty list List<String> list = new ArrayList<>(); // Check if the list is empty if (list.isEmpty()) { System.out.println("The list is empty"); } else { System.out.println("The list is not empty"); } } }
Medium
medium.com › @AlexanderObregon › java-set-isempty-method-explained-16a8a18f4c63
Java Set.isEmpty() Method Explained | Medium
June 23, 2024 - This means that isEmpty() can be used with any type of collection, such as List, Queue, and Map (through its key, value, or entry set). import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; public class CollectionIsEmptyExample { public static void main(String[] args) { List<String> list = new ArrayList<>(); Set<String> set = new HashSet<>(); // Checking if list is empty if (list.isEmpty()) { System.out.println("The list is empty."); } // Checking if set is empty if (set.isEmpty()) { System.out.println("The set is empty."); } // Adding elements list.add("Element1"); set.add("Element1"); // Check again if (!list.isEmpty()) { System.out.println("The list is not empty."); } if (!set.isEmpty()) { System.out.println("The set is not empty."); } } } Output: The list is empty.