0

Hello developers, please who can help explain this multi dimensional arrays

26th Aug 2018, 2:41 AM
Lawal Adekunle Jimoh
Lawal Adekunle Jimoh - avatar
4 odpowiedzi
+ 4
Let me re-format one line int[][] sample = { {1, 2, 3}, // array 0 {4, 5, 6} // array 1 }; sample is an array that holds arrays of integers. sample[1] is {4, 5, 6} if you take that and select the first element sample[1][0] you get 4
26th Aug 2018, 2:55 AM
voidneo
+ 2
It's very simple actually. Think of them like arrays where you save other arrays.
26th Aug 2018, 2:45 AM
voidneo
+ 1
int[ ][ ] sample = { {1, 2, 3}, {4, 5, 6} }; int x = sample[1][0]; System.out.println(x); // Outputs 4 Please what does this code explain
26th Aug 2018, 2:48 AM
Lawal Adekunle Jimoh
Lawal Adekunle Jimoh - avatar