Java Reference
In-Depth Information
3. Verify that the Text option button and the Match case checkbox are
selected in the Conditions area. Verify that the Active document option
button is selected in the Scope area. Click the Replace All button. Click
the Close button.
All occurrences of the phrase, throws Exception, now are changed to, throws
PasswordException, throughout the entire Password class (Figure 10-24).
text replaced with
phrase, throws
PasswordException
FIGURE 10-24
OTHER WAYS
Each of the four constructors in the Password class claims a PasswordException
because they each call the set() method, which can create more than one type of
password exception. Similarly, the validate() and verifyFormat() methods can cre-
ate more than one type of password exception, whether due to password expira-
tion or to an invalid password value. When generating an exception, these
methods do not create a PasswordException object, as that class is abstract and
cannot be used for creating objects. Instead, one of the subclasses of the
PasswordException class — which are specific, concrete classes — must be used.
Any subclass of PasswordException may be referenced more generally
as a PasswordException. Therefore, a method that claims (throws) a
PasswordException actually may be throwing any of the concrete subclass
objects of PasswordException. In this way, only one exception must be listed
in the throws clause for each method, rather than listing all specific types of
exceptions that the method may throw. The exception still may be caught by
its more specific reference, for example, as a PasswordInvalidException or a
1. Press ALT + S , R
2. Press F8
Search WWH ::




Custom Search