Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

Handling an Entire Class Hierarchy of Exceptions
We can actually catch more than one type of exception in a single catch clause. If the exception class that we specify in the catch clause has no subclasses, then only the specified class of exception will be caught. However, if the
class specified in the catch clause does have subclasses, any exception object that subclasses the specified class will be caught as well.We could write a catch clause like
the following:
try {
// Some code here that can throw a boundary exception
}
catch (IndexOutOfBoundsException e) {
e.printStackTrace();
}