throw StatementPurpose:
- Executed to indicate that an exception has occurred.
Mechanics:
throw new <Throwable>;orthrow e; // where e is an instance of the Throwable class or one of its subclasses
Example:
throw new Exception();
Usage:
- <Throwable> must be the Throwable class or one of its subclasses.
- When a method throws an exception, it should declare the
exceptions it may throw in the method declaration using the
throwsstatement.
email suggestions to: cs015tas@cs.brown.edu
