Summary

Now that you have put Java's exception-handling techniques to use, I hope the subject of errors is a little more popular than it was at the beginning of the hour.

You can do a lot with these techniques:

  • Catch an exception and deal with it

  • Ignore an exception, leaving it for another class or the Java interpreter to take care of

  • Catch several different exceptions in the same try-catch block

  • Throw your own exception

Managing exceptions in your Java programs makes them more reliable, more versatile, and easier to use, because you don't display any cryptic error messages to people who are running your software.

Once you're comfortable handling errors, you can even use assertions to create more of them—as a safeguard against the times when your ...

Get SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.