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