Two-dimensional arrays
The array is a reference data type, and the default value is null.
Defines a one-dimensional array in the form of:int[] i = new int[];
It can be seen that each element of a one-dimensional array is an int, then the two-dimensional array is originally each element is now changed to every array, that is, int[].
So the definition of a two-dimensional array is:
int[] [] i = new int [4][5];//red indicates second dimension
The structure of the two-dimensional array in memory:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/74/F3/wKioL1YvPZ3BXjaLAAFH5pOkvxI366.jpg "title=" Qq20151027165715.png "alt=" Wkiol1yvpz3bxjalaafh5pokvxi366.jpg "/>
Exceptions in the array:
1 array subscript out of bounds: java.lang.ArrayIndexOutOfBoundsException
int[] i = new int[3];
for (int m = 0;m <= i.length;m++)
{
System.out.println (I[m]);
}
2 exception for null pointer: java.lang.NullPointerException
(1)
boolean[] i = new boolean[3];
i = null;
System.out.println (I[0]);
(2)
string[] str = new STRING[3];
System.out.println (Str[0]);
(3)
Int[][] J = new int[3][];
J[2][1] = 8;
System.out.println (j[2][1]);
Basic Java Learning 10