Types of Errors
- Syntax
- Run-Time (these show up as Exceptions in Java)
- Logic
Exception Class Hierarchy
- Throwable
- Error
- Exception
- RunTimeException (unchecked)
- other exceptions (checked)
- Look at Throwable class methods
- Error: due to serious external conditions, e.g. computer is
out of memory
- Unchecked Exception: typically due to a programming error, e.g.
divide by zero
- Checked Exception: typically not due to programmer error,
e.g. unavailable data file
- Look at Figure 2.2
Catching and Handling Exceptions
- try-catch construct
- try-catch-finally construct
Class Code