0
Hello developers, please who can help explain this multi dimensional arrays
4 Respostas
+ 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
+ 2
It's very simple actually. Think of them like arrays where you save other arrays.
+ 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