Yes.
In fact, when you declare and initialize an array of object references, all the values inside it will be null by default. Remember that the length of an array will never vary, despite the contents (null elements) in the array. There's a difference between length and size, the length is how many elements can be stored in an array, while the size is the amount of valid elements in the array. Also, an array is not a list.
Example:
String[] stringArray = { null, null };
System.out.println(stringArray.length);
stringArray[0] = "hello";
stringArray[1] = "world";
System.out.println(stringArray.length);
Prints:
2
2
From JLS(emphasis mine):
An array object contains a number of variables. The number of variables may be zero, in which case the array is said to be empty. (...) If an array has n components, we say n is the length of the array; the components of the array are referenced using integer indices from 0 to n - 1, inclusive
(...)
Once an array object is created, its length never changes.
(...)
An array is created by an array creation expression (§15.10.1) or an array initializer (§10.6)
An array creation expression specifies the element type, the number of levels of nested arrays, and the length of the array for at least one of the levels of nesting. The array's length is available as a final instance variable length.
An array initializer creates an array and provides initial values for all its components.
(...)
The length of the array to be constructed is equal to the number of variable initializers immediately enclosed by the braces of the array initializer. Space is allocated for a new array of that length. If there is insufficient space to allocate the array, evaluation of the array initializer completes abruptly by throwing an OutOfMemoryError. Otherwise, a one-dimensional array is created of the specified length, and each component of the array is initialized to its default value.
(...)
- The public final field
length, which contains the number of components of the array. length may be positive or zero.
From here, you may understand the following:
- When you initialize an array, you have to define at least the length of the first level (a.k.a. dimension). If you have an array of a single level, then this length will be the length of the whole array.
- When the array is initialized, all its components (a.k.a. elements) are initialized with the default value of the type. For primitive types, it may be
0 or false (depends on the type). For object references, it's null.
- The length of an array represents how many components can have.
- An array has a fixed length. This length cannot be changed.
Again, the length of an array (how many components can store) is not the same as the size of an array (how many components that we consider proper values is storing at the moment).