java运行异常的示例
- java语言
- 关注:1.75W次
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]);
}
}
- 文章版权属于文章作者所有,转载请注明 https://xuezhezhai.com/jsj/java/53n6pv.html