Java Reference
In-Depth Information
01 MYSUB2-CONTROL.
03 MYSUB2-ACTION-SWITCH PIC X.
88 MYSUB2-ACTION-INITIALIZE VALUE "I".
88 MYSUB2-ACTION-EVALUATE VALUE "E".
88 MYSUB2-ACTION-SET-AND-EVALUATE VALUE "S".
88 MYSUB2-ACTION-GET-CALL-COUNTER VALUE "G".
03 MSG-TEXT PIC X(20).
03 MSG-SIZE PIC 9(8).
03 MYSUB2-RETURNED-CALL-COUNTER PIC 9(10).
03 MYSUB2-PRIVATE-ITEMS PIC X(20).
Suppose that the MSG-TEXT items in both MYSUBx-CONTROL areas con-
tained the same text (“Some Text,” for example). In this case, this COBOL code
would display a message:
IF MSG-TEXT OF MYSUB1-CONTROL = MSG-TEXT OF MYSUB2-CONTROL
DISPLAY "MSG-TEXT's are equal".
However, this COBOL code may or may not display a message, depending on
the value of the other items in the MYSUBx-CONTROL areas:
IF MYSUB1-CONTROL = MYSUB2-CONTROL
DISPLAY "MYSUBx-CONTROL's are equal".
When you compare object reference variables (including a String object refer-
ence variable) with the == Java operator, it is as if you are comparing two CON-
TROL areas in COBOL. In order to compare the MSG-TEXT items in the
CONTROL areas, you must explicitly compare just those items. Likewise, in order
to compare text in a Java String , you must use the equals() method and not com-
pare the object reference variables.
E XERCISES : J AVA ' S S YNTAX
It's time to visit the example classes again and try out all these new ideas.
1. Edit the HelloWorld.java source file in your java4cobol directory with a
text editor. You'll start by deleting the code that experimented with inher-
itance. Remove the lines after this statement (but remember to leave in the
two curly braces at the end of the program):
Search WWH ::




Custom Search