Java Reference
In-Depth Information
// Print the contents of ErrorMsgs String data member directly.
System.out.println (myErrorMsg.msgText);
Add these bolded lines:
// Get the translation for this method.
tempMsg = myErrorMsg.getTranslation ();
System.out.println (tempMsg);
6. Save, compile, and rerun the HelloWorld application.
javac HelloWorld.java
java HelloWorld
The output should look like this:
Hello World!
Some Text
Some Text
Some Text
7. Edit the HelloWorld application, and set LANGUAGECODE to F. Add
this bolded line after the statement that creates ErrorMsg :
// Create a new instance of the ErrorMsg class:
ErrorMsg myErrorMsg = new ErrorMsg ();
TextMessage.LANGUAGECODE = 'F';
8.
Save, compile, and rerun the HelloWorld application, and observe the output:
Hello World!
Some Text
Some Text
Some Text -> French Text
9. Create a new instance of ErrorMsg , and test how it performs translations.
Add these bolded lines to the end of HelloWorld:
// Create a new instance of the ErrorMsg class.
ErrorMsg myErrorMsg2 = new ErrorMsg ();
// Set the text item to some text String, and print its contents.
Search WWH ::




Custom Search