throws Java Keyword

The throws keyword may be applied to a method to indicate the method raises particular types of exceptions.

Examples

  import java.io.IOException;
  
  public class MyClass
  {
     public method readFile(String filename) throws IOException
     {
        <statements>
        if (error)
        {
           throw new IOException("error reading file");
        }
     }
  }
  

Remarks

Related Topics

catch Java Keyword

finally Java Keyword

throws Java Keyword

try Java Keyword