5.1.4+Describe+the+characteristics+of+a+twodimensional+array

Two-dimensional arrays are used whenever the model data is best represented with rows and columns, or has two varying aspects (eg, gender and age, weight and height, ...).

Each cell of the array is a variable that can hold a value and works like any variable. As with one dimensional arrays, every cell in a 2D array is of the same type.

Important: Each cell of the array is specified with a row and column number, in that order.

2-dimensional arrays are usually represented with a row-column "spreadsheet" style. Assume we have an array, "a", with two rows and four columns.

int[][] a = new int[2][4]; // Two rows and four columns.

[2] || a[0][3] ||  || You can assign initial values to an array in a manner very similar to one-dimensional arrays, but with an extra level of braces. The dimension sizes are computed by the compiler from the number of values. This would allocate a 3x3 board
 * a[0][0] || a[0][1] || a[0]
 * a[1][0] || a[1][1] || a[1][2] || a[1][3] ||  || Two-dimensional arrays are usually visualized as a matrix, with rows and columns. This diagram shows the array "a" with its corresponding subscript ||

<span style="font-family: Arial,Helvetica,sans-serif;">int[][] board = new int[][] {{1,0,0},{0,1,0},{1,2,1}};