File: EmptyArray.java
class EmptyArray {
public static void main (String args[]) {
Object[] array = new Object[] {};
/*
Notice that this is very different from
Object[] nullArray = null;
array.length == 0
but nullArray.length generates a Null Pointer Exception.
*/
System.out.println(array.length);
}
}
|
Java - Empty Array |