在Java中明确规定对于RuntimeException的异常类型可以有选择性地进行处理,如果不处理则出现异常时交给JVM默认处理。
常见的RuntimeException类型的异常有:NumberFormatException、ClassCastException、NullPointerException、ArithmeticException、ArrayIndexOutOfBoundsException。
Exception和RuntimeException的区别?
Exception:强制性要求用户必须处理。
RuntimeException:是Exception的子类,是由用户选择是否进行处理。