int[ ][ ] myArr = { {1, 2, 3}, {4}, {5, 6, 7} }; myArr[0][2] = 42; int x = myArr[1][0]; // 4 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

int[ ][ ] myArr = { {1, 2, 3}, {4}, {5, 6, 7} }; myArr[0][2] = 42; int x = myArr[1][0]; // 4

in this syntax we didn't declare 3 dimension array so what is the position of 4 and why?And how it is 3*3 array if it is 2 dimensional

29th Jun 2017, 9:48 AM
Narayan K
Narayan K - avatar
1 Answer
+ 10
int[ ][ ] myArr = { {1, 2, 3}, {4}, {5, 6, 7} }; // declares a 2D, 3x3 array in the form of 1 2 3 4 - - 5 6 7 myArr[1][0] will correspond to the second row, first column, which is 4.
29th Jun 2017, 9:51 AM
Hatsy Rei
Hatsy Rei - avatar