请说明 Throwable→Error/Exception 的结构、checked 与 unchecked 异常的划分及实践建议。
体系:所有异常的根是 Throwable,下分:
OutOfMemoryError、StackOverflowError、NoClassDefFoundError;- 受检异常(Checked):编译器强制 try-catch 或 throws 声明。发生在编译期可预见的外部问题——IOException、SQLException、ClassNotFoundException;
- 非受检异常(Unchecked,RuntimeException 及其子类):多为程序 bug——NullPointerException、IndexOutOfBoundsException、IllegalArgumentException、ArithmeticException。不强制捕获。
实践建议:
题目与答案就在本页;收藏、批注和错题重练在应用内