+ 1
What is the error in this code?
I want to extract all the elements of this multidimensional array.. public class Program { public static void main(String[] args) { int[ ][ ] myArr = { {1, 2, 3}, {4}, {5, 6, 7} }; myArr[0][2] = 42; for(int x : myArr) { System.out.println (x) } } }
3 Answers
+ 1
you don't have a semicolon at the end of system.out.println(x)
Edit:
You also need to add a [] where the int x is,
also add another for each loop, for example:
for(int []x : myArr){
for(int y: x){
System.out.println(y);
}
System.out.println();
}
0
okay...but i didn't understand "also add another for each loop"!!
also i am not getting it while coding..will u please code it and send it to me!!!
please