Living with Exceptions
In Java, exceptions occur when some non-planned issue occurs that interrupts the normal flow of execution. Exception handling is accomplished in one of two general ways. The first is to simply allow the exception to propagate up the call stack. This is accomplished by adding the throws keyword and a list of exception types to the method declaration. The second approach is to execute code that may throw an exception inside of a try block. Immediately following the try block will be one or more catch blocks that catch the different exception types that may occur in the preceding try block. The catch block(s) may be followed by a finally block that is used for cleanup.