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 - The array is not empty. Explanation: The isArrayNotEmpty method checks both conditions (array != null and array.length > 0) and returns a boolean result. Java 8 introduced streams, which can also be used to check if an array contains elements.
🌐
Scaler
scaler.com › home › topics › check and declare empty array in java
Check and Declare Empty Array in Java - Scaler Topics
November 16, 2023 - An array can be considered an empty array java if the array displays the value NULL. ... In the above example, we have declared an array dates and assigned the values null. The 'if condition' will compare the dates with null.
🌐
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
If the compilation is successful, you will see no output. A ArrayLengthCheck.class file will be created in the ~/project directory. Now, run the compiled program using the java command: ... This output confirms that our program correctly identified the empty array and the populated array based on their lengths. Checking the length of an array before attempting to access its elements is a crucial step to prevent errors like ArrayIndexOutOfBoundsException, which occurs when you try to access an element at an index that doesn't exist in the array.
🌐
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 - Example: The simplest way to determine if an array is empty is by evaluating its length or verifying if it is null. This approach ensures our code handles both uninitialized and empty arrays effectively.
🌐
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
An array is said to be an empty array, if the array has zero element or no element in it. Let's explore the article to see how it can be done by using Java programming language. ... Suppose the original array is {1,3}. After checking if it is empty or not the result will be ?
🌐
Coderanch
coderanch.com › t › 384533 › java › check-Input-array-null-empty
check Input array null or empty (Java in General forum at Coderanch)
The books might have suggested NOT to catch and i think you might have got confused with "Catching Vs Checking". 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!
Find elsewhere
🌐
W3Schools
w3schools.com › java › ref_arraylist_isempty.asp
Java ArrayList isEmpty() Method
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Server Java Syllabus Java Study Plan Java Interview Q&A Java Certificate · ❮ ArrayList Methods · Check if a list is empty: import java.util.ArrayList; public class Main { public static void main(String[] args) { ArrayList<String> cars = new ArrayList<String>(); System.out.println(cars.isEmpty()); cars.add("Volvo"); cars.add("BMW"); cars.add("Ford"); cars.add("Mazda"); System.out.println(cars.isEmpty()); } } Try it Yourself » ·
🌐
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?
🌐
Quora
quora.com › How-do-I-check-if-array-is-empty-or-not
How to check if array is empty or not - Quora
Answer (1 of 19): Question: How do I check if array is empty or not? You fail to mention the language - In Java it’s simple: Assuming you have an array called arr, simply test arr.length for > 0. If true, it’s not empty. Also a little more complex - if you use the java.util.Arrays class ...
🌐
Java Code Geeks
javacodegeeks.com › home › core java
Check Array Is Null or Empty Example - Java Code Geeks
September 23, 2024 - Line 30: test_ApacheObjectUtils_isEmpty checks if an array is empty via Apache ObjectUtils.isEmpty method.
🌐
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 - Check the length of the array using the ‘length’ variable. The Java array object has a variable named ‘length’ that stores the number of elements in the array. If the length is zero, the array is empty.
🌐
OneCompiler
onecompiler.com › questions › 3xmsra8yt › -java-how-to-check-if-given-array-is-empty
[Java] How to check if given array is empty? - Questions - OneCompiler
We need to check if the value is not null and the length is greater than zero to make sure array is not empty. Following code shows how to do that · public class JavaArrays { public static void main(String[] args) { String[] colors = { "red", "green", "blue", "orange", "maroon" }; String[] ...
🌐
TutorialKart
tutorialkart.com › java › java-array › java-check-if-array-is-empty
Java - Check if Array is Empty
November 23, 2020 - The array is empty. To check if an array has no elements, get length property of the array and check if the length is zero.
🌐
YouTube
youtube.com › hey insights
How to Check if an Array is Empty in Java? - YouTube
How to Check if an Array is Empty in Java?In this tutorial, you will learn how to check if an array is empty in Java. We will cover different methods and app...
Published   February 10, 2025
Views   2
🌐
Quora
quora.com › How-do-you-check-if-a-string-array-is-empty
How to check if a string array is empty - Quora
Answer (1 of 2): In Java, you can check if a string array is empty by using the [code ]length[/code] property of the array, which returns the number of elements in the array. Here's an example: [code]Copy codeString[] myArray = new String[0]; ...