The common exceptions in the array are: 1, array subscript out of bounds exception 2, array null pointer exception, and NULL pointer exception is divided into 3 kinds, the code example is as follows:
public class Exception1 {
public static void Main (string[] args) {
1, array subscript subscript out of bounds exception: Java.lang.ArrayIndexOutOfBoundsException
int[] I=new int[10];
i[10] = 8;//subscript out of bounds
System.out.println (i[10]);
2. Null pointer exception java.lang.NullPointerException
First Kind
boolean[] B=new boolean[3];
b=null;//null pointer exception appears here
System.out.println (b[0]);
The second Kind
string[] Str=new string[5];
str[4]=new String ("AA");//or write str[3]= "AA" without writing this sentence will appear null pointer exception
System.out.println (str[4].tostring ());
Third Kind
Int[][] J=new int[3][];
j[1][0]=6;//first address is NULL, unable to find the specified value
}
}
Exceptions that are common in arrays