- 1

public class Program { public static void main(String[] args) { int[ ][ ] myArr = { {1, 2, 3}, {4}, {5, 6, 7} }; myArr[0][2] = 42; int x = myArr[1][1]; System.out.println(x); } } why it does not give any garbage value as output?

9th Nov 2016, 6:21 PM
Sandesh
4 Réponses
0
your array is 3 dimention int[][][] and your output would be myArr[0][2] = 3
9th Nov 2016, 6:37 PM
Wanderlei Borges
Wanderlei Borges - avatar
0
myArr[1][1] is not exist. only [1][0] is exist and the value is 4. In the next, [2][0] is 5, [2][1] is 6 ... understand?
9th Nov 2016, 6:48 PM
Lauren Ldp
Lauren Ldp - avatar
0
You code can't run,because the element was not defined.
11th Nov 2016, 12:31 AM
Ceng Shaw
Ceng Shaw - avatar
0
it will give the output as 0
16th Nov 2016, 5:39 PM
Prashantha M.P
Prashantha M.P - avatar