Specifications
Sun Services
Java™ Programming Language
Module 8, slide 14 of 25
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
The Handle or Declare Rule
Use the handle or declare rule as follows:
• Handle the exception by using the
try-catch-finally block.
• Declare that the code causes an exception by using the
throws clause.
void trouble() throws IOException { ... }
void trouble() throws IOException, MyException { ... }
Other Principles
• You do not need to declare runtime exceptions or
errors.
• You can choose to handle runtime exceptions.










