How to check if an array is empty in Java?

To check if an array is empty in Java do this: array.length == 0.

Here's how you do it:

int[] nonEmptyArray = new int[] { 1, 2, 3 };
int[] emptyArray = new int[] {};

System.out.println(nonEmptyArray.length == 0); // false
System.out.println(emptyArray.length == 0); // true