Exceptions: Specifying the Exceptions Thrown by a Method

Specifying the Exceptions Thrown by a Method

public void writeList() throws IOException, IndexOutOfBoundsException {
   ...
}

To specify that method can throw an exception, add a throws clause to the method declaration for the method. The throws clause comprises the throws keyword followed by a comma-separated list of all the exceptions thrown by that method. The clause goes after the method name and argument list and before the brace that defines the scope of the method.

Related concepts

Specifying the Exceptions Thrown by a Method

Exceptions: Specifying the Exceptions Thrown by a Method — Structure map

Clickable & Draggable!

Exceptions: Specifying the Exceptions Thrown by a Method — Related pages: