Java Reference
In-Depth Information
For example, this infrastructure can be extended to support standard pagina-
tion functions when every line is printed. These pagination functions might include
the ability to print standard heading information as necessary at the beginning of
every page, as well as other page management functions.
For the last exercise, you will experiment with the concept of polymorphism.
So far, two classes, ErrorMsg and PrintfileErrorMsg , contain a method named
setErrorMsg . The one defined in PrintfileErrorMsg is an overridden version of the
method defined in ErrorMsg . You will create a third version of this method in an
unrelated class called Diagnostic . You will then have HelloWorld call each of these
methods and examine what happens as a result.
25. Create a new java source file in the C:\java4cobol directory named Diag-
nostic.java. Insert these lines of text into the class file definition:
import java.util.*;
//
// Diagnostic
//
//
public class Diagnostic {
// Define a setErrorMsg method. This method will write an error message to
// the system diagnostic output.
public static void setErrorMsg (String inputMsg) {
// Print a banner.
System.err.println ("====== A serious error has occurred ====
== ");
Date today = new Date();
System.err.println (today);
System.err.println ();
// Print the message.
System.err.println (inputMsg);
// Print a banner end.
System.err.println ();
System.err.println ();
Thread.dumpStack();
System.err.println ();
System.err.println ("====== End of serious error message ===
==");
}
}
Search WWH ::




Custom Search