文章字数:97,阅读全文大约需要1分钟
RuntimeException 和 Exception
相同
RuntimeException继承与ExceptionRuntimeException和Exception都能被try...catch
不同
- 如果程序抛出
Exception,编译器会要求代码中处理,即try...catch或throws RuntimeException可以不在代码中处理,运行时遇到则会抛出。例如空指针异常
1 | public static void main(String[] args) { |