• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes
24 views

Problem :

java does not limit the number of dimensions that an array may have

by (6.9k points)  

1 Answer

0 votes

Solution :

The Java language does not limit the number of dimensions in an array but the Java VM spec limits the number of dimensions in an array to 255.

For example, the following code will fail to compile

class Main {
    public static void main(String[] args) {
        final int[][][][][][][][][][][][][][][][]
                 [][][][][][][][][][][][][][][][]
                 [][][][][][][][][][][][][][][][]
                 [][][][][][][][][][][][][][][][]
                 [][][][][][][][][][][][][][][][]
                 [][][][][][][][][][][][][][][][]
                 [][][][][][][][][][][][][][][][]
                 [][][][][][][][][][][][][][][][]
                 [][][][][][][][][][][][][][][][]
                 [][][][][][][][][][][][][][][][]
                 [][][][][][][][][][][][][][][][]
                 [][][][][][][][][][][][][][][][]
                 [][][][][][][][][][][][][][][][]
                 [][][][][][][][][][][][][][][][]
                 [][][][][][][][][][][][][][][][]
                 [][][][][][][][][][][][][][][][] x;
    }
}
with error

1.java:18: error: array type has too many dimensions
                 [][][][][][][][][][][][][][][][] x;
                                                  ^
1 error

by (33.3k points)  
edited by
...