Java examples for Language Basics:throw
To throw an exception in a method, add the throws keyword after the method's closing parenthesis.
Here's an example:
public void getPoint (int x, int y) throws NumberFormatException { }
If your method might throw multiple types of exceptions, declare them all in the throws clause separated by commas:
public void storePoint (int x, int y) throws NumberFormatException, EOFException { }
You can use a superclass of a list of exceptions to tell that your method might throw any subclass of that exception.
For instance:
public void loadPoint () throws IOException { }