- Create and use exceptions in Java
- syntax:
try {
... code with possible exception ...
} catch (ExceptionClassName e) {
... code to run if exception is thrown ...
}
- you can have multiple catch clauses (for each type of possible exception)
- examples will be illustrated using posted demonstration programs
- TestException1.java: a non-compiling exception demonstration
- TestException2.java: a non-compiling exception demonstration
- TestException3.java: specifying but not catching an exception
- TestException4.java: catching an exception demonstration
- TestException5.java: displaying a special exception message