try { // statements which might throw an ArithmeticException // or some type of RunTimeException } catch ( ArithmeticException ex ) { // statements to handle this // type of exception } catch ( RunTimeException ex ) { // statements to handle this // type of exception } // Statements following the structure
A more compact way of showing the hierarchy is:
Exception IOException AWTException RunTimeException ArithmeticException NoSuchElementException InputMismatchException IndexOutOfBoundsException ArrayIndexOutOfBoundsException Others Others
Don't memorize this diagram (for one thing, it is far from complete). But look at it to see what it says.
Which should come first in the catch
blocks:
ArithmeticException
or IndexOutOfBoundsException
?