Introduction

Get introduced to the concept of error handling.

Error handling in Java

In Java, when an error occurs in the normal flow of a program, an Exception is thrown. A try/catch statement can then be used to recover from the Exception and perform the appropriate fallback behavior, or in other words, ignore the error and continue, retry the operation, display an error message to the user, and so on. Most Exception events that are handled in this manner are checked exceptions.

  • Checked exceptions: The thrown Exception needs to be declared and explicitly handled for our code to compile.
  • Unchecked exceptions: These are harder to catch and, if not handled, can cause our application to crash.

Oftentimes, this is not the ideal behavior because we want apps to perform well despite these edge cases.

Get hands-on with 1200+ tech skills courses.