填空题

Java中数组下标越界时,会引发( )异常。访问Null的对象时会引发( )异常。

参考解答

  • ArrayIndexOutOfBoundsException
  • NullPointerException

常见的运行时异常

异常名称 何时发生
NullPointerException String str = null; str.toUpperCase();
ArrayIndexOutOfBoundsException System.out.println((new int[0])[0]);
ClassCastException Object a = ""; Integer b = (Integer)a;
IllegalArgumentException enum Color{ red , blue } Color.valueOf("green");
UnsupportedOperationException Arrays.asList("a","b").add("c");
ConcurrentModificationException for(Integer i:list){list.remove(i);}

results matching ""

    No results matching ""