O'Reilly logo

Special Edition Using Java 2 Standard Edition by Geoff Friesen, Chuck Cavaness, Brian Keeton

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

Catching and Throwing Exceptions

When you write programs using Java, sooner or later (and probably much sooner) you're going to run into exceptions. An exception is a special type of object that is created when something goes wrong in a method. The rest of your program is notified about a problem when a method performs an action called throwing an exception. When an exception is thrown, it's up to your program to catch the exception and handle it.

Using try/catch/finally

In some of the previous chapters, you've gotten a quick look at exceptions and how they are handled in a program. An exception is thrown when a method call cannot complete successfully. You can prevent some exceptions by guarding actions that have the potential to cause an error. ...

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