next up previous
Next: The most common types Up: Unit 10 Previous: The hierarchy of exceptions

How to handle exceptions

There are two possibilities for handling exceptions:

If the exception is not handled, instead, the program terminates and prints out a message.

For example, if we try to do a division by zero, we obtain:

Exception in thread "main" java.lang.ArithmeticException: / by zero
  at DivByZero.main(DivByZero.java:7)


next up previous
Next: The most common types Up: Unit 10 Previous: The hierarchy of exceptions