Java Reference
In-Depth Information
// Experiment with Java statements.
String testMsg = myErrorMsg.getErrorMsg ();
if (myErrorMsg.getErrorMsg ().equals (testMsg)) {
System.out.println ("testMsg = ErrorMsg text");
}
7. Save, compile, and rerun the HelloWorld application.
javac HelloWorld.java
java HelloWorld
The output should look like this:
...
testMsg = ErrorMsg text
8. Next, add this additional bolded Java code:
// Experiment with Java statements.
String testMsg = myErrorMsg.getErrorMsg ();
if (myErrorMsg.getErrorMsg ().equals (testMsg)) {
// Define a temporary integer variable.
int i = 5;
System.out.println ("testMsg = ErrorMsg text");
System.out.println ("i = " + i);
}
9. Compile and rerun the HelloWorld application. The output should look
like this:
...
testMsg = ErrorMsg text
i = 5
10.
Next, you'll explore how parentheses can modify the results of a statement.
Using a text editor, add these bolded lines to the end of your HelloWorld.java
source file.
int x, y, z;
x = 3;
y = 4;
z = x + 1 * 2;
System.out.println ("z = " + z);
Search WWH ::




Custom Search