O'Reilly logo

Oracle Certified Associate, Java SE 7 Programmer Study Guide by Richard M. Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exception handling guidelines

This section addresses general guidelines for working with exceptions. It is intended to provide examples of how to use exception handling in a more useful and productive manner. While poor techniques may not result in a compile-time error, or an incorrect program, they often reflect a poor design.

Repeating code that threw an exception

When an exception is thrown and then caught we will sometimes want to try and re-execute the offending code. This is not difficult if the code is structured properly.

In this code sequence, errors are assumed to be present when the try block is entered. If an error is generated it is caught and handled by the catch block. As the errorsArePresent is still set to true, the try block will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required