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: