public void test2() {
//ArrrayIndexOutOfBoundsException
1.ArrrayIndexOutOfBoundsException数组角标越界异常
int[] arr = new int[3];
System.out.println(arr[4]);// 空
// NullPointerException
2.NullPointerException空指针异常
int[] arr2 = null;
System.out.println(arr2[1]);// 空
}
3.ClassCastException类型转换异常
public void test3() {
Object obj = new Date();
String str = (String) obj;//向下转型
}
4.NumberFormatException数字格式化异常
public void test4() {
String str = "123";
int num = Integer.parseInt(str);
String str = "abc";
int num1 = Integer.parseInt(str);
}
5.INput
c