/*
数组的常见异常:
1.数组下标越界异常:ArrayIndexOutOfBoundsException
2.空指针异常:NullPointerException
*/
class Demo{
public static void main(String[] args){
int[] intArray = {1,3,4};
System.out.println(intArray[0]);
// System.out.println(intArray[3]);//编译通过;运行时:ArrayIndexOutOfBoundsException异常
int[] intArray2 = {1,3,65};
int[] intArray3 = intArray2;
intArray3[0] = 1000;
System.out.println(intArray2[0]);//1000
intArray2 = null;//老公已经无家可归
System.out.println(intArray2[0]);//编译通过:运行时:NullPointerException
intArray2 = new int[]{1,43,24,3};
}
}
|
|