Java Reference
In-Depth Information
public class ErrorMsg extends TextMessage {
public void setErrorMsg (String inputMsg) {
...
// Some logic
...
}
}
// Define a method named getTranslation. This method overrides the
// method with the same name in the base class.
public String getTranslation () {
// Call the base object's method.
String localString = super.getTranslation ();
// Since this is an error message, change it to all uppercase.
// Perform the toUpperCase function (this is a method that every String has).
localString = localString.toUpperCase ();
return (localString); }
}
The class hierarchy for ErrorMsg does not change, even though you are per-
forming a new function (see Figure 5.4).
FIGURE 5.4
The class hierarchy for ErrorMsg .
Search WWH ::




Custom Search