
David W. answered 09/25/22
retired
int[][] myVals ={{2, 4, 6, 8}, {20, 40, 60, 80}};;
A 2D integer array named myVals is declared and initialized. "int[][] myVals " names the array myVals, declares it to be of type "int", and says it will be two dimensions by including "[][]".
Now, the two rows of data are initialized by "={{2, 4, 6, 8}, {20, 40, 60, 80}}", Notice that the elements of each row are separated by commas, then the row of elements is placed in curly braces ( "{" and "}" ).
See the table above.
References are of the form: Array [rownum][colnum].
So, myVals[1][2] refers to the second row (that is, number 1) and the third position (that is, number 2). Be careful to start your numbering with 0 (that is -- 0,1,2,3).
MyVals[1][2] = 60 (see the picture}