7.7. Review notes

This section lists the main points of all the sections covered in this chapter.

Why handle exceptions separately:

  • Handling exceptions separately enables you to define the main logic of your code together.
  • Without the use of separate exception handlers, the main logic of your code would be lost in combating the exceptional conditions. (See figure 7.5 for an example.)
  • Exception handlers separate the concerns of defining regular program logic from exception-handling code.
  • Exceptions help pinpoint the offending code, together with the method in which it’s defined, by providing a stack trace of the exception or error.
  • The JVM may send the stack trace of an unhandled exception to the Java console.

Categories of exceptions:

Get OCA Java SE 8 Programmer I Certification Guide 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.