There's a key difference between a null array and an empty array. This is a test for null.

int arr[] = null;
if (arr == null) {
  System.out.println("array is null");
}

"Empty" here has no official meaning. I'm choosing to define empty as having 0 elements:

arr = new int[0];
if (arr.length == 0) {
  System.out.println("array is empty");
}

An alternative definition of "empty" is if all the elements are null:

Object arr[] = new Object[10];
boolean empty = true;
for (int i=0; i<arr.length; i++) {
  if (arr[i] != null) {
    empty = false;
    break;
  }
}

or

Object arr[] = new Object[10];
boolean empty = true;
for (Object ob : arr) {
  if (ob != null) {
    empty = false;
    break;
  }
}
Answer from cletus on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ java-array-empty-check
Java Array Empty Check - GeeksforGeeks
July 23, 2025 - While this method is more complex for basic checks, it is useful when we want to extend the logic (e.g., filtering elements). ... // Java Program to check if array // is not empty using streams import java.util.Arrays; public class ArrayCheckWithStreams { public static void main(String[] args) { int[] arr = {1, 2, 3}; // Check if the array is not null and contains // at least one element using streams if (arr != null && Arrays.stream(arr).findAny().isPresent()) { System.out.println("The array is not empty."); } else { System.out.println("The array is empty."); } } }
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ what-is-arrayutilsisempty-in-java
What is ArrayUtils.isEmpty in Java?
isEmpty is a static method of the ArrayUtils class that checks whether the given array is empty or null.
๐ŸŒ
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?
๐ŸŒ
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); } }
๐ŸŒ
W3Schools
w3schools.com โ€บ java โ€บ ref_arraylist_isempty.asp
Java ArrayList isEmpty() Method
Arrays Loop Through an Array Real-Life Examples Multidimensional Arrays Code Challenge ยท Java Methods Java Method Challenge Java Method Parameters
๐ŸŒ
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.
Find elsewhere
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
Vultr
docs.vultr.com โ€บ java โ€บ standard-library โ€บ java โ€บ util โ€บ ArrayList โ€บ isEmpty
Java ArrayList isEmpty() - Check If Empty | Vultr Docs
November 5, 2024 - The isEmpty() method in Java's ArrayList class is a straightforward tool to check if the list contains no elements. It returns true if the list is empty; otherwise, it returns false.
๐ŸŒ
Java2Blog
java2blog.com โ€บ home โ€บ core java โ€บ java array โ€บ check if array is empty in java
Check if Array Is Empty in Java - Java2Blog
March 4, 2022 - The Apache commons library provides the isEmpty() method in the ArrayUtils class. This method can be used to check if the array is empty in Java.
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java array โ€บ checking if an array is null or empty in java
Checking if an Array Is Null or Empty in Java | Baeldung
July 16, 2024 - Apache Commons Lang 3 is a widely used library. Its ArrayUtils class provides a rich set of utilities, making array manipulation easier. The class offers an isEmpty() method to check whether an array is null or empty.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ how-to-check-if-an-array-is-empty-or-not-in-java
How to Check if an Array is Empty or Not in Java? - GeeksforGeeks
July 23, 2025 - // Java Program to Check if an Array // is Empty using Optional Class import java.util.Optional; public class ArrayCheck { public static void main(String[] args) { int[] arr = {}; // Example array // Use Optional.ofNullable to // handle null checks gracefully boolean isEmpty = Optional.ofNullable(arr) .map(arr1 -> arr1.length == 0) .orElse(true); System.out.println("" + isEmpty); } }
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ check and declare empty array in java
Check and Declare Empty Array in Java - Scaler Topics
November 16, 2023 - The ArrayUtils.isEmpty(dates) method will loop through each element in the dates and compare it with null. If any item does not equal null then the boolean value isEmpty will be assigned false and we will break the loop.
๐ŸŒ
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?
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-to-check-if-an-array-is-empty-or-not-in-java
How to Check if an Array is Empty or Not in Java
By Using User Defined Method and length() Method. By Using null Check. Let's see the program along with its output one by one. In this approach, array elements will be initialized in the program.
๐ŸŒ
Java Code Geeks
javacodegeeks.com โ€บ home โ€บ core java
Check Array Is Null or Empty Example - Java Code Geeks
September 23, 2024 - Line 37: test_emptyCheck checks if an array is empty via testClass.isEmpty method.
๐ŸŒ
TutorialKart
tutorialkart.com โ€บ java โ€บ java-array โ€บ java-check-if-array-is-empty
Java - Check if Array is Empty
November 23, 2020 - Java ArrayList ยท ArrayList add() ArrayList addAll() ArrayList clear() ArrayList clone() ArrayList contains() ArrayList ensureCapacity() ArrayList forEach() ArrayList get() ArrayList indexOf() ArrayList isEmpty() ArrayList iterator() ArrayList lastIndexOf() ArrayList listIterator() ArrayList remove() ArrayList removeAll() ArrayList removeIf() ArrayList removeRange() ArrayList retainAll() ArrayList set() ArrayList size() ArrayList spliterator() ArrayList subList() ArrayList toArray() ArrayList trimToSize() Java HashMap ยท