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
🌐
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 - Explanation: The array == null checks if the array reference is uninitialized or null and the array.length == 0 checks if the array has no elements. If we need to check arrays frequently, we can create a reusable utility method to simplify array ...
🌐
Coderanch
coderanch.com › t › 384533 › java › check-Input-array-null-empty
check Input array null or empty (Java in General forum at Coderanch)
In another word, if we don't add the NullPointerException, at the runtime, if the input array is null, JVM will throw NullPointerException automatically,"Exception in thread "main" java.lang.NullPointerException" You have told very clearly through the words "don't add the NullPointerException" -- that is for adding a catch block!
🌐
Delft Stack
delftstack.com › home › howto › java › how to check whether an array is null empty
How to Check Whether an Array Is Null/Empty in Java | Delft Stack
February 2, 2024 - If you are working with Apache then use ArrayUtils class to check whether an array is empty. The ArrayUtils class provides a method isEmpty() which returns a boolean value either true or false.
🌐
Baeldung
baeldung.com › home › java › java array › null array to empty list in java
Null Array to Empty List in Java | Baeldung
April 7, 2025 - We’ll accept a possiblyNullArray as our method argument, and return a non-null list that contains all the values from the original array. Importantly, if the original array is null or empty, our final list will be empty. Now, let’s look at a few approaches. In our first implementation, we’ll use the Java Streams API.
🌐
Java Code Geeks
javacodegeeks.com › home › core java
Check Array Is Null or Empty Example - Java Code Geeks
September 23, 2024 - I tested the methods with Junit ... ArrayUtils.isEmpty methods from Apache Common Library. As you can see from the test results, the native methods have better performance. This was an example of a maven project which includes an array check null or empty features. Download You can download the full source code of this example here: Check Array Is Null or Empty Example · Do you want to know how to develop your skillset to become a Java ...
🌐
LabEx
labex.io › tutorials › java-how-to-check-if-an-array-is-empty-in-java-560002
How to Check If an Array Is Empty in Java | LabEx
Learn how to check if an array is empty in Java. This lab covers checking array length, handling null arrays, and testing with different array types. Master Java array emptiness checks.
Find elsewhere
🌐
Baeldung
baeldung.com › home › java › java array › difference between null and empty array in java
Difference Between null and Empty Array in Java | Baeldung
August 10, 2024 - When we instantiate an empty array, Java allocates memory for the array structure but stores no elements. It’s important to note that when we create a non-empty array without specifying values for its elements, they default to zero-like values — 0 for an integer array, false for a boolean array, and null for an object array:
🌐
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.
🌐
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 - It means that the allMatch() method returns true if all the elements of the array have null values. ... 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.
🌐
W3Docs
w3docs.com › java
How can I check whether an array is null / empty?
To check if an array is null in Java, you can use the == operator and compare the array to null. For example: int[] arr = null; if (arr == null) { System.out.println("Array is null"); } To check if an array is empty, you can use the length field ...
🌐
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
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-array-empty-check
Java Array Empty Check - GeeksforGeeks
July 23, 2025 - In Java, an array is considered non-empty, if it is not null and its length is greater than 0.
🌐
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 isEmpty() function takes an array as a parameter. Then it will check if the parameter passed to it is null or empty. If the array passed as a parameter is null or empty then it would return a true.