up previous next contents
Next: try, catch, and finally Up: Exceptions Previous: throw   Contents

Subsections

The throws clause

  • The exceptions a method can throw are declared with a throws clause.
  • The exceptions a method can throw are as important as the value type the method returns.

Choices when invoking a method that has a throws clause

  • Catch the exception and handle it.
  • Catch the exception and map it to one of your exceptions by throwing an exception of a type declared in your own throws clause.
  • Declare the exception in your throws clause and let the exception pass through your method.


up previous next contents
Next: try, catch, and finally Up: Exceptions Previous: throw   Contents