1arr = new int[0];
2if (arr.length == 0) {
3 System.out.println("array is empty");
4}
5
1Object arr[] = new Object[10];
2boolean empty = true;
3for (Object ob : arr) {
4 if (ob != null) {
5 empty = false;
6 break;
7 }
8}
9
1public class test {
2
3 public static void main(String[] args) {
4 Object[][] someArray = new Object[5][];
5 someArray[0] = new Object[10];
6 someArray[1] = null;
7 someArray[2] = new Object[1];
8 someArray[3] = null;
9 someArray[4] = new Object[5];
10
11 for (int i=0; i<=someArray.length-1; i++) {
12 if (someArray[i] != null) {
13 System.out.println("not null");
14 } else {
15 System.out.println("null");
16 }
17 }
18 }
19}
20
21$ /cygdrive/c/Program\ Files/Java/jdk1.6.0_03/bin/java -cp . test
22not null
23null
24not null
25null
26not null
27
1Object arr[] = new Object[10];
2boolean empty = true;
3for (int i=0; i<arr.length; i++) {
4 if (arr[i] != null) {
5 empty = false;
6 break;
7 }
8}
9