java运行异常的示例

来源:文书网 2.02W

NullPointerException:空指针异常类

java运行异常的示例

示例:

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]);

}

}

热门标签