TopMore string operationsExceptions

Exceptions

[Only cover first 4 sections of this chapter now. Other parts will come when we talk about streams.]

We have seen exceptions all semester long:

These are just a few examples of a more general system provided by Java (and some other programming languages) to deal with errors called exceptions.

We will look at what exceptions can do for us and how Java implements them using variants of this Color Mixer program covered earlier:

Demo: Color Mixer

In this simple version, things work fine, until we enter non-numerical text. When this is passed to Integer.parseInt, a NumberFormatException is thrown.


TopMore string operationsExceptions