Chapter 15 - Exception Handling: Finally Printstacktrace
Chapter 15 - Exception Handling: Finally Printstacktrace
Chapter 15 - Exception Handling: Finally Printstacktrace
15.1 Introduction
• Exception handling
– Exception
• Indication of problem during execution
– E.g., divide by zero
– Chained exceptions
• Superclass Throwable
– Subclass Exception
• Exceptional situations
• Should be caught by program
– Subclass Error
• Typically not caught by program
• Checked exceptions
– Catch or declare
• Unchecked exceptions
Throwable
Throwable
Exception Error
• Resource leak
– Caused when resources are not released by a program
• The finally block
– Appears after catch blocks
– Always executes
– Use to release resources
Method throwException
Finally is always executed
Exception handled in main