Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Java Objects!
You have completed Java Objects!
Preview
Exceptions are everywhere in Java. Let's learn to love them. Let's learn how to throw and handle exceptions in our code, so we can explain when our code is being misused.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Now, luckily, Java provides a way for us
0:00
to let the user of our objects
know when they've done something wrong.
0:01
I'm talking about exceptions.
0:05
It's possible for us to tell the consumer
0:07
that we are having problems
with how they're using our object.
0:09
Stated in another way,
0:13
we can let them know
that an exceptional event has occurred,
0:14
and it's possible for the user to handle
or catch that exception.
0:18
The way we do this on the usage side of
things is known as a try-catch block.
0:22
Let's go use it.
0:27
Java comes with some built-in exceptions
and you can create your own.
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up