0

How to find output?

How do you know what the output of a double array? For example, if the code is: int[][] myArr = {{1,2,3}.{4,5,6}}; int x = myArr[2][1]; System.out.println(x); //*how do you know what the output is?

12th Jun 2019, 3:32 PM
Viren Gadkari
Viren Gadkari - avatar
2 odpowiedzi
0
this code doest work: - you need to sepperate the array with a "," not a "." - you say myArr[2][1] but the first number is the row, and the scond number is the number in that row
12th Jun 2019, 4:02 PM
Cat Sauce
Cat Sauce - avatar
0
The two arrays have an index (starts at 0) and each value have an index (starts at 0) First array (1,2,3) myArr[0][0] - myArr[0][2] Second array (4,5,6) myArr[1][0] - myArr[1][2] 5 -> myArr[1][1] 2 -> myArr[0][1] 4 -> myArr[1][0] myArr[2][1] does not exist.
12th Jun 2019, 4:42 PM
Denise Roßberg
Denise Roßberg - avatar