Skip to main content
Formatting
Source Link
Lii
  • 12.1k
  • 9
  • 69
  • 92

This is correct.

A[] a = new A[4];

creates...creates 4 AA references, similar to doing this:

A a1;
A a2;
A a3;
A a4;

nowNow you couldn't do a1.someMethod()a1.someMethod() without allocating a1 asa1 like this:

a1 = new A();

similarlySimilarly, with the array you need to do this:

a[0] = new A();

before...before using it.

This is correct.

A[] a = new A[4];

creates 4 A references, similar to doing this

A a1;
A a2;
A a3;
A a4;

now you couldn't do a1.someMethod() without allocating a1 as

a1 = new A();

similarly, with the array you need to do

a[0] = new A();

before using it.

This is correct.

A[] a = new A[4];

...creates 4 A references, similar to doing this:

A a1;
A a2;
A a3;
A a4;

Now you couldn't do a1.someMethod() without allocating a1 like this:

a1 = new A();

Similarly, with the array you need to do this:

a[0] = new A();

...before using it.

"creates 4 A variables" became "creates 4 A references" for clarity.
Source Link

This is correct.

A[] a = new A[4];

creates 4 A variablesreferences, similar to doing this

A a1;
A a2;
A a3;
A a4;

now you couldn't do a1.someMethod() without allocating a1 as

a1 = new A();

similarly, with the array you need to do

a[0] = new A();

before using it.

This is correct.

A[] a = new A[4];

creates 4 A variables, similar to doing this

A a1;
A a2;
A a3;
A a4;

now you couldn't do a1.someMethod() without allocating a1 as

a1 = new A();

similarly, with the array you need to do

a[0] = new A();

before using it.

This is correct.

A[] a = new A[4];

creates 4 A references, similar to doing this

A a1;
A a2;
A a3;
A a4;

now you couldn't do a1.someMethod() without allocating a1 as

a1 = new A();

similarly, with the array you need to do

a[0] = new A();

before using it.

Source Link
MeBigFatGuy
  • 28.7k
  • 8
  • 64
  • 68

This is correct.

A[] a = new A[4];

creates 4 A variables, similar to doing this

A a1;
A a2;
A a3;
A a4;

now you couldn't do a1.someMethod() without allocating a1 as

a1 = new A();

similarly, with the array you need to do

a[0] = new A();

before using it.