Language syntax

Java throws clause

Declares possible escaping exceptions in a method signature.

Formal Syntax & Structure

java syntaxjava
void load() throws IOException

Working Example

Example Snippetjava
import java.io.IOException;public class Main {    static void read() throws IOException { throw new IOException("Unavailable"); }    static void load() throws IOException { read(); }    public static void main(String[] args) {        try { load(); } catch (IOException e) { System.out.println("Load failed: " + e.getMessage()); }    }}
Java Reference