Sams Teach Yourself Java™ in 24 Hours (Covering Java 7 and Android)

(singke) #1
ptg7068951

Summary 261

To correct the problem causing the “no protocol” error, edit Line 16 so the
string begins with the text http://like the other web addresses in Lines
7–14. When you run the program again, you see the output shown in
Figure 18.3.


FIGURE 18.3
The output of the PageCatalog
application.

Summary


Now that you have put Java’s exception handling techniques to use, the
subject of errors ought to be a bit more popular than it was at the begin-
ning of the hour.


You can do a lot with these techniques:


. Catch an exception and deal with it.
. Ignore an exception, leaving it for another class or the Java inter-
preter to take care of.
. Catch several different exceptions in the same try-catchblock.
. Throw your own exception.


Managing exceptions in your Java programs makes them more reliable,
more versatile, and easier to use because you don’t display any cryptic
error messages to people who are running your software.

Free download pdf