Try...Catch...Finally

Learn to handle errors during program execution.

We'll cover the following

Introduction

Program errors are unavoidable. They can happen because our application is trying to reach a server that’s not responding, or they may occur because we run out of computer memory, or maybe because our program is trying to read a non-existent file. In any case, it’s likely that an exception occurs.

Exceptions are program states where it can no longer continue to run, so we have to address them.

Consider the following example. We create a size four array, but access the fifth element (which doesn’t exist). This produces an exception:

Get hands-on with 1200+ tech skills courses.