Exception class Hierarchy
The exception class hierarchy starts with the java.lang.Throwable
class. When an exception is thrown, it must be the Throwable
object of the class or any of its subclasses.
catch
The parameters of a block must be of Throwable
type or its subclasses, for example: Exception
, ArithmeticException
, and IOException
so on.
You can create your own defined exception class by inheriting an exception class class.
Organization arranges multiple catch blocks
The Java runtime selects the appropriate catch
blocks and looks for the appropriate blocks from the first block in the order they are catch
started catch
.
try
Multiple blocks of a block catch
must be arranged from the most specific exception type to the most common exception type.
The following code uses catch
a valid sequence of multiple blocks.
ArithmeticException
A class is a RuntimeException
subclass of a class.
If both exceptions are try
handled in blocks of the same catch
block, then the most specific type, that is ArithmeticException
, must precede the most common type, before the RuntimeException
exception class.
Click on the link to view the details
Java Exception class