DRAFT
Observed
Arrays are created without the new keyword
All arrays are allocated on the heap with new
Arrays are allocated on the heap.
They are a special kind of object.
To allocate them, one needs to use new
in almost all situations.
So, to allocate the above array, one needs to write new Integer[3]
.
char[] a;
a = new char[12]; // new required
a = new char[] {'A', 'B', 'C'}; // new required
However, there is an exception:
initializers in array variable declarations
do not need to specify the array type and the new
:
char[] a = new char[] {'A', 'B', 'C'};
char[] a = {'A', 'B', 'C'}; // ok
The following papers directly or indirectly provide qualitative or quantitative evidence related to this misconception.