Java syntax: Difference between revisions

Content deleted Content added
Line 1,345:
The <code>throws</code> keyword indicates that a method throws an exception. All checked exceptions must be listed in a comma-separated list.
<syntaxhighlight lang="java">
// Indicates thatimport java.io.IOException may be thrown;
import java.util.zip.DataFormatException;
void operateOnFile(File f) throws IOException {
 
// Indicates that IOException and DataFormatException may be thrown
void operateOnFile(File f) throws IOException, DataFormatException {
// ...
}