+ 10
David has explained this well, but I try to explain it in a slightly different way.
A multidimensional array is an array that contains arrays. So, elements of multidimensional array are arrays and is written as: [ ][ ]
As you know, the array element's positions start from 0 (zero) :
int [] arr ={2,4,6}
arr[0] = 2;
arr[1] = 4;
arr[2] = 6
It is same with multidimensional array.
For example :
We have array arr which elements are 3 arrays : {1,2,3} ,{4,5} and {6,7,8,9}
int arr [ ] [ ] ={{1,2,3}, {4,5}, {6,7,8,9}}
Output: arr[2] [0] =?
[2] *** First brackets [ ] indicates the element of array arr. If we know that elements of arr are arrays too, we need find array on position 2 (remember : position of elements start at zero). This is array {6,7,8,9}.
[0] *** Second brackets [ ] indicates the element of array that we found before {6,7,8,9}
Position of elements start at zero, so element on position [0] is 6.
Result: arr[2][0] =6
Example II:
arr[0][1] =2 => array on position [0] is {1,2,3} and element of this array on position [1] is 2.
Example III:
arr[1] [1] = 5
etc...
+ 9
Ill try and keep this simple for yea..
int i [][] = {{1,2,3},{4,5,6},{7,8,9}};
When you have a single array you have 1 box [] after your variable which selects the the element only.
When you have a multidimensional array you have 2 boxes [][] after your variable or before dosent matter..
*When you print*
The first box selects the row of elements and the second box selects the element inside.
Remember java counts from 0 to 1 so row 1 is 0 and element 1 inside that row is 0.
If you print [0][0] the first element in the first row will output 1.
If i printed [2] <<row [2] << element the output will be 9
it looks like this
0,1,2 <<selecting row
0,1,2 <<selecting elements
hope that helps
+ 5
https://code.sololearn.com/cwCwJ42dkhko/?ref=app
Small vizualization:)