1.异常分类
1.顶级接口:Throwable,子接口:Error和Exception。 Error一般表示的是JVM异常,程序无法处理。
2.Exception分为两类:RunTimeException和非运行时异常。
RunTimeException:程序中无需进行捕获
非运行时异常:程序中必须进行捕获。
2.常见的运行时异常
1.AthematicException:算数异常,如当进行除法运算时,若未检查被除数是否为0,则可能出现该异常。
2.NullPointerException:空指针异常
3.ClasscastException :类型转化异常
4.ArrayIndexOutofException:数组下标越界
5.StringIndexOutOfBounds:字符串下标越界
6.InvalidClassException:序列化时,若序列号ID前后不一致,反序列化会出现该异常。