How many array dimension is supported in Java like a[1][1][1][1]....[1]
?
Can I declare an unlimited number of dimensions for an array?
The Java language does not limit the number of dimensions, but the Java VM spec limits the number of dimensions to 255. (Ref: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.1 "An array type descriptor is valid only if it represents 255 or fewer dimensions.")
No, Java does not support multi-dimensional arrays.
More than Three Dimensions Although an array can have as many as 32 dimensions, it is rare to have more than three. When you add dimensions to an array, the total storage needed by the array increases considerably, so use multidimensional arrays with care.
The number of array dimensions are limited to 255.
The interesting thing is that there is no such limitation in Java programming language defined by JLS, but you can see in the JVM specification, that the array dimension is stored in 1 byte.
However, you can hardly meet this limitation on your day-to-day development. :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With