• Register
0 votes
80 views

Problem :

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

6 5 3
6,930 points

Please log in or register to answer this question.

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

9 7 4
38,600 points

Related questions

1 vote
2 answers 284 views
284 views
Problem : I am beginner to numpy. I am trying to execute my code but I am facing below error. “Valueerror: all the input arrays must have same number of dimensions”. I want to have my all the arrays with a same shape. I am trying to fix above error from past couple of days but still unable to fix it. I am looking for some help in fixing above error.
asked Apr 4, 2020 morrisBson 3.2k points
0 votes
1 answer 16 views
16 views
Problem: I am a novice Java programmer who started learning to program in Java just a few weeks ago. I got an assignment from my tutor in which I have to write a program that prints the sum of the elements of a given array. The output of the program should be ... } I am allowed to take help from the Internet so asking for help from you guys. Can anybody please provide me with a solution? Thanks!
asked Dec 29, 2020 Code Learner 5.5k points
0 votes
1 answer 1K views
1K views
Problem : I am getting bellow error can only iterate over an array or an instance of java.lang.iterable
asked Nov 1, 2019 peterlaw 6.9k points
0 votes
1 answer 11 views
11 views
I have a blog website. In this website in several blogs. so from these blog post i need to remove duplicate elements from an array.
asked Sep 28, 2020 Daniel Anderson 4k points
1 vote
1 answer 31 views
31 views
Problem : I am very new to programming. I have recently started learning C programming. Please find below the one way of initializing the array: I have one doubt about my above program : Which of the following is not a correct way to initialize an array? int n[ 5 ] = { 0, 7, 0, 3, 8, 2 }; int m[3] = ... [1] 15};     printf("m[0] = %d  m[1] = %d   m[2] = %d\n", m[0], m[1], m[2]);     return 0; }
asked Apr 27, 2020 stewart 4k points
0 votes
1 answer 90 views
90 views
Solutions: I am new in programming and my logic is not good, can anyone give the right solution? Write an expression that evaluates to true if and only if the C-string s equals the C-string "end"?
asked Feb 14, 2020 maddi86 5.4k points
1 vote
1 answer 210 views
210 views
Problem : I am new to C programming. I have recently started working on exercise. Please find below my code for your reference: int mydistinct(int a[], int n) { int i, k, j, count=0; int max = a[0]; for (i = 1; i < n; i++) { if (max < a[i]) { ... . In this case my code will only try to count 8,7,6,5 and it will return only four unique numbers. So I am looking for proper guidance in C programming.
asked May 19, 2020 Martin K 6.6k points
0 votes
1 answer 8 views
8 views
Problem: The easiest way to create an array of structures is to use the REPLICATE function. The first parameter to REPLICATE is a reference to the structure of each element. Using the example in and assuming the STAR structure has been defined, an array containing 100 elements of the structure is created with the following statement: cat = REPLICATE({star}, 100)
asked Dec 5, 2020 Mashhoodch 5.7k points
0 votes
1 answer 49 views
49 views
Problem: Hi there! I am new here in this magical world of programming and currently I am learning and trying to grasp things in Java. My question is about arrays in Java. I know how to declare and initialize arrays but I want to know that is this necessary to specify ... of array each time I declare an array? Moreover, is specifying the size of array mandatory? What if I skip any of these two?
asked Nov 30, 2020 Code Learner 5.5k points
1 vote
1 answer 366 views
366 views
Problem : I am very new to programming. I need to write a program called swapAdj that must accept the array of integers and after that swap those elements at the adjacent indexes. For example consider the elements 0 and 1 are swapped by the program and after ... note if your array has the odd length then the program must keep final element unmodified. Please help me in writing above program.
asked Apr 7, 2020 morrisBson 3.2k points