The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

cassisian (28) [Avatar] Offline
1) "The array declaration only creates a variable that refers to null, as shown in figure 4.23."

The sole declaration of a variable never initializes it.
Constructs with initialization like "Person person = new Person();", "int[] a = {0, 1};" or "int a = 0;" are a different case.
Therefore, the mentioned variable can not refer to null.

2) "NOTE Arrays can be of any data type other than null."

null is not a data type, it is a literal value of type object reference. I would suggest to drop the "other than null" part.

Message was edited by: cassisian, reformatted it only
DMForcier (14) [Avatar] Offline
Re: Chapter 4, page 199, two errors
The first statement refers to a declaration such as int[] intArray;

Internally, the declaration does not allocate space (on the heap or stack) for the variable. After mere declaration, the variable cannot be referenced programmatically (compiler error) and does not appear in the Eclipse debugger.

With no space allocated, one cannot say that "the declaration ... creates a variable", and one certainly cannot say that the variable has a value, even null.

I completely agree on the second point.
cassisian (28) [Avatar] Offline
Re: Chapter 4, page 199, two errors
Elaborating on the first point:

int[] intArray;

If it would occur as static class member meaning

class MyClass {
static int[] intArray;

or even if it would occur as normal class member meaning

class MyClass {
int[] intArray;

then intArray would refer to null when the class is loaded or an instance is created.

Else, as stated on page 381: "…, and by default, local variables aren't assigned a value --- not even a null value."