by eternalvoyage · 3y ago · 0 comments
* Java arrays can have 0 dimensions
* When declaring arrays, trailing comma is allowed after the last element
* In multi-dimensional arrays, only the last dimension contains actual values. Other dimensions are just pointers to arrays.
Good read.
The way you've phrased it is a bit ambiguous.
Having 0 dimension sounds like
x = new int[7][5]; // 2 dimensions
y = new int[9]; // 1 dimension
z = new int; // no dimensions, not an array, not allowed
The phrasing you mean is "dimensions can have zero size".> (It’s somewhat counterintuitive that the zero dimension is not the first one in the array.)
"Dimensions" plural agrees with "zero" as a count, so that reads as "the count of dimensions is zero".
But they used singular "dimension" with "the" which treats "zero" as an adjective. It means "the dimension that is zero".
Out of curiosity, how do you rate each of:
"Arrays can have a zero dimension."
"Arrays can have two zero dimensions."
"Arrays can have some zero dimensions."
"Arrays can have zero dimensions."
in this regard?