Java Reference
In-Depth Information
Self-Test Exercises (continued)
catch (NegativeNumberException e)
{
System.out.println("First catch.");
}
catch (Exception e)
{
System.out.println("Second catch.");
}
System.out.println("End of exercise.");
20. Suppose that in Self-Test Exercise 19 the line
n = 42;
is changed to
42;
n =
How would this affect the output?
21. Suppose that in Self-Test Exercise 19 the line
n = 42;
is changed to
n = 0;
How would this affect the output?
9.2
Throwing Exceptions in Methods
buck n. Games. A counter or marker formerly passed from one poker
player to another to indicate an obligation, especially one's turn to deal.
THE AMERICAN HERITAGE DICTIONARY OF THE ENGLISH LANGUAGE,
THIRD EDITION
The buck stops here.
HARRY S TRUMAN (sign on Truman's desk while he was president)
So far our examples of exception handling have been toy examples. We have not yet
shown any examples of a program that makes good and realistic use of exception han-
dling. However, now you know enough about exception handling to discuss more
realistic uses of exception handling. This section explains the single most important
Search WWH ::




Custom Search