7.1. Exceptions in Java
[8.3] Describe the advantages of Exception handling
In this section, you’ll learn what exceptions are in Java, why you need to handle exceptions separately from the main code, and all about their advantages and disadvantages.
7.1.1. A taste of exceptions
In figure 7.1, do you think the code in bold in the classes ArrayAccess, OpenFile, and MethodAccess has anything in common?
Figure 7.1. Getting a taste of exceptions in Java
I’m sure, given this chapter’s title, that this question was easy to answer. Each of these three statements is associated with throwing an exception or an error. Let’s look at them ...