Chapter 11

Throwing and Catching Exceptions in Java

Perhaps the most important aspect of writing a complete and useful Java program is dealing with exceptions to its intended execution. To paraphrase an old piece of wisdom, a program runs well for just one reason, but it can fail for all sorts of reasons. Writing a solid program has to do with good design and focusing on correct results. Protecting a program from failure has to do with checking every operation that could go sideways and providing a remedy. I’ll discuss how the exception system works in the Java language and the tools at your disposal to implement it.

In this chapter, we’ll cover the following topics:

  • Understanding the role exceptions play
  • Using a try-catch block
  • Understanding ...

Get Java SE 7 Programming Essentials now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.