The catch Blocks

The catch Blocks

try {

} catch (ExceptionType name) {

} catch (ExceptionType name) {

}
  • You associate exception handlers with a try block by providing one or more catch blocks directly after the try block. No code can be between the end of the try block and the beginning of the first catchblock.
  • Each catch block is an exception handler that handles the type of exception indicated by its argument. The argument type, ExceptionType, declares the type of exception that the handler can handle and must be the name of a class that inherits from the Throwable class. The handler can refer to the exception with name.
  • The catch block contains code that is executed if and when the exception handler is invoked.

Related concepts

The catch Blocks — Structure map

Clickable & Draggable!

The catch Blocks — Related pages: