Exception Hierarchy in Java – Diagram

In Java, exception can be checked or unchecked. They both fit into a class hierarchy. The following diagram shows Java Exception classes hierarchy.

Red colored are checked exceptions. Any checked exceptions that may be thrown in a method must either be caught or declared in the method’s throws clause. Checked exceptions must be caught at compile time. Checked exceptions are so called because both the Java compiler and the Java virtual machine check to make sure this rule is obeyed.

Green colored are uncheck exceptions(运行时异常). They are exceptions that are not expected to be recovered, such as null pointer, divide by 0, etc.

Exception Hierarchy in Java – Diagram_第1张图片

转载于:https://my.oschina.net/u/148367/blog/170991

你可能感兴趣的:(Exception Hierarchy in Java – Diagram)