Exceptions and Advanced File I/O I
- Contents
- Exceptions
- Why Exceptions?
- Exception Classes
- Handling Exceptions
- Polymorphic References to Exceptions
- Handling Multiple Exceptions
- The
finally
Clause - The Stack Trace
- Uncaught Exceptions
- Checked and Unchecked Exceptions
- Throwing Exceptions
Exceptions
The Java programming language uses exceptions to handle runtime errors and other exceptional events.
An exception is an event that occurs during the execution of a program that disrupts the normal flow of instructions.
Exception are said to have been “thrown”.
It is the programmer’s responsibility to write code that detects and handles exceptions.
Unhandled exceptions will crash a program.
Book example:
Example code: