YourWalkOnTech

Enjoy your walk on technology

What "handle an exception" means

A comprehensive guide to

handling

exceptions

in

Java

: we'll firstly understand how to decide how to

handle

an

exception

, and then we'll discover the three ways to

handle

an

exception

: delegate the calling method to do so, completely

handle

the

exception

in the current method, or a mix of these two ways.
Useful resources
The video page on YouTube.                                                                                                                                                                                                                                                                                 
The video's slides.                                                                                                                                                                                                                                                                                         
In cases where we do not know how to

handle

an

exception

in the current method, we can delegate the calling method, which will then receive the

exception

and decide how to

handle

it. In this example we see the case of a

checked

exception

.
In cases where we do not know how to

handle

an

exception

in the current method, we can delegate the calling method, which will then receive the

exception

and decide how to

handle

it. In this example we see the case of an

unchecked

exception

.
An

exception

can be completely handled in the current method; in that case the calling method will never know that an

exception

has occurred. In this example we see the case of a

checked

exception

.   
An

exception

can be completely handled in the current method; in that case the calling method will never know that an

exception

has occurred. In this example we see the case of an

unchecked

exception

and why this is not really the correct way to

handle

an

unchecked

exception

.
In this example we see that, in the case of an

unchecked

exception

, it is preferable to prevent the

exception

from occurring rather than letting it be thrown and then handled by

try

/

catch

blocks or by the

throws

keyword.
In this example we see that an

exception

, whether

checked

or

unchecked

, can be partially handled in the current method and then forwarded to the calling method for further

handling

.