Java Reference
In-Depth Information
Hello World!
Some Text
Some New Text
C:\java4cobol>
6.
Experiment with this program. Add the following lines to the end of
your HelloWorld.java source file (i.e., immediately after the last println
statement):
// Create a new instance of the ErrorMsg class.
ErrorMsg myErrorMsg2 = new ErrorMsg ();
// Set the text item to some text String, and print its contents.
myErrorMsg2.setErrorMsg ("Some Text for #2");
tempMsg = myErrorMsg2.getErrorMsg ();
System.out.println (tempMsg);
// Print the text item in the original object.
tempMsg = myErrorMsg.getErrorMsg ();
System.out.println (tempMsg);
7.
Save the program again. Compile and execute it by performing these state-
ments in the command window:
javac HelloWorld.java
java HelloWorld
Your DOS window should look like this:
C:>javac HelloWorld.java
C:>java HelloWorld
Hello World!
Some Text
Some New Text
Some Text for #2
Some New Text
C:\java4cobol>
Search WWH ::




Custom Search