About two-dimensional arrays in Java [instance]:
Public class lesson{public static void Main (String [] args) {//two-D array declaration://data type [] [] Array name = new data type [length] [length];//Data class Type [[] Array name = {{123},{456}}; /* int [] [] arr = {{123},{456}}; Defines a two-dimensional array of two rows of three columns and assigns a for (int x = 0; x<arr.length; x + +) {//positioned row for (int y = 0; y<arr[x].length; y++) {//Locate the number of elements per row System. Out.print (Arr[x][y]); } System.out.println ("n"); } */int [] num = new int [3][3]; Two-dimensional array num[0][0 with three rows and three columns defined] = 1; Assign a value to the first element of the first line num[0][1] = 2; Assign a value to the second element in the first row num[0][2] = 3; Assign a value to the third element in the first row num[1][0] = 4; Assign a value to the first element of the second line num[1][1] = 5; Assign the second element to the second row num[1][2] = 6; Assign a value to the third element of the second line num[2][0] = 7; Assign a value to the first element of the third line num[2][1] = 8; Assign a value to the second element of the third row num[2][2] = 9; Assign a third row to the third element for (int x = 0; x<num.length; x + +) {//Locate line for (int y = 0; y<num[x].length; y++) {//Locate the number of elements per row System.out. Print (Num[x][y]); } System.out.println ("n"); }}//array value Arr[x][y] represents the value specified in column y of line X. When using a two-dimensional array object, note the length represented by length, and/or the array name, followed by a direct length (such as Arr.length), which refers to a few rows (row);//Specify the index followed by length (such as Arr[0].length), Refers to the element that the row owns, that is, the number of columns (column).