DRAFT
ArrayLengthCannotBeZero
Misconception:
It is not possible to create an array of length 0.
Incorrect
An array cannot have a length of 0 elements
Correct
An array can have a length of 0 elements
CorrectionHere is what's right.
Here is what's right.
We can allocate an array of length zero in exactly the same way we can allocate arrays of any other length:
new int[0]
And we can also use an array initializer instead of specifying the length:
new int[] {}
OriginWhere could this misconception come from?
Where could this misconception come from?
Students might mistakenly believe that an empty array is not really an array, similar to the mistaken believe that 0 is not really a number.
Language
Java