Diagram of Exception Hierarchy

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.


Check out top 10 questions about Java exceptions.

Category >> Diagram >> Exceptions  
If you want someone to read your code, please put the code inside <pre><code> and </code></pre> tags. For example:
String foo = "bar";

  1. Ali on 2011-11-28

    What these colours show, which are checked Exceptions and which are unchecked exceptions.

  2. ron on 2011-11-28

    darker colored are checked exceptions. Checked exceptions must be caught at compile time. Runtime exceptions do not need to be. Errors often cannot be, as they tend to be unrecoverable.

  3. james on 2013-7-16
  4. […] 3. Java 异常类层次 […]

  5. azizkhani on 2013-10-3

    very nice

  6. […] 3. Java 异常类层次 […]

  7. dmi on 2013-10-18

    it’s very useful and clear information, thanks!

  8. paul on 2013-10-31

    nice !

  9. […] Exception Hierarchy in Java […]

  10. […] 异常处理类结构 […]

  11. […] used checked exception and RuntimeException is an unchecked exception. You can check out the exception hierarchy diagram before reading the […]

  12. […] 3、Java异常类的层次结构 […]

  13. […] 3、Java异常类的层次结构 […]

  14. gry www on 2014-9-1

    gry www

    Exception Hierarchy in Java

  15. […] 3.  Java异常类的层次结构 […]

  16. […] 3、Java异常类的条理组织 […]

  17. Govind Rai on 2014-11-23

    Very Helpful! Thanks

  18. […] 3、Java异常类的层次结构 […]

  19. […] 3、Java异常类的层次结构 […]

  20. […] 3、Java异常类的层次结构 […]

  21. […] 3、Java异常类的层次结构 […]

  22. Alpesh katariya on 2015-10-23

    I m understand properly see this diagram.

  23. Veaceslav Gaidarji on 2016-9-29

    I wouldn’t say that “Green colored are uncheck exceptions.” they are green on the diagram, it’s more azure or light blue 🙂

  24. vikram on 2016-11-28

    nice one

Leave a comment