//1、定义一个对象为Null,尝试用此引用调用方法,把这个调用放在try-catch子句里以捕获异常
//2、编写一个能捕获ArrayIndexOutOfBoundsException异常的代码
public class TestDemo3 {
public static void main(String[] args) {
try{
int[] array = {1,2,3,4};
System.out.println(array[4]);
}catch (ArrayIndexOutOfBoundsException e){
e.printStackTrace(System.out);
}
}
public static void main1(String[] args) {
String str = null;
try {
int len = str.length();
}catch (NullPointerException e){
e.printStackTrace();
}
}
}