Java提供了两类主要的异常:runtime exception和checked exception。checked 异常也就是我们经常遇到的异常,以及SQL异常都是这种异常。以下是小编为大家搜索整理的java运行异常分析,希望能给大家带来帮助!更多精彩内容请及时关注我们应届毕业生考试网!
NullPointerException:空指针异常类
示例:
package c;
public class Test {
public static void main(String[] args) {
tln(toUpper(null));
}
public static String toUpper(String str){
return perCase();
}
}
异常信息如下: Exception in thread "main" PointerException
at per()
at (:6)
ArrayIndexOutOfBoundsException:数组下标越界异常
示例:
package c;
public class Test {
public static void main(String[] args) {
int[] a = {0,1,2,3};
tln(a[4]);
}
}
异常信息如下:
Exception in thread "main" yIndexOutOfBoundsException: 4
at (:7)