First format:
1 Public classarray_twodimension {2 Public Static voidMain (string[] args) {3 int[] arr1 =New int[3] [4];//defines a two-dimensional array of arr1, representing 3 one-dimensional arrays in a two-dimensional array, with four elements in each one-dimensional array4 5ARR1[0][3] = 78;//This is the value of the third corner in the first array in the two-dimensional array6 7System.out.println (ARR1);//The address of the array is printed, which is one more than one-dimensional array [8System.out.println (Arr1[0]);//The address of an array , which is the address value of the first array in a two-dimensional array9System.out.println (arr1[0][1]);//The elements of the array are printed .Ten One A int[] arr2 =New int[3] [];//3 represents the length of a two-dimensional array a one-dimensional array in a two-dimensional array is null -System.out.println (arr2[0][1]);//result is null - } the}
The second type of format:
1 Public class array_twodimension {2 Public Static void Main (string[] args) {3 int [] Arr3 = {{3,4,5,6},{5,5,6,6},{8,7,5,3}}; 4 System.out.println (arr3[0].length); // Print the length of the first one-dimensional array in a two-bit array 5 }6 }
Definition of a two-dimensional array