Friday, December 31, 2021

Replace nested-if's with proper exception-handling

" 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."

OCA Java SE 8 Programmer I Certification Guide  by Mala Gupta