Java Exception handling and hierarchy

18-Sep-2024

Understand the hierarchy of exceptions in Java for better error handling


Java Exception handling 


Exception handling is a mechanism to handle runtime error. It's make sure that the normal flow of the program is maintained.

In Java, Exception is the unwanted or unexpected event, which occurs during the execution of program. When an exception occurs it's create a object. And this object called exception object. This exception object  contains information about the exception


Java Exception hierarchy


Java exception hierarchy is structured with the base class Throwable. And under the Throwable There are two main branch or subclasses Exception and Error.


below the Java exception hierarchy is given:





Types of Exception:

Exception are mainly two types checked and unchecked.


Comments