Java Reference
In-Depth Information
TABLE 7.1 JAVA FLOW CONTROL OPERATORS
Construct
Description
COBOL Equivalent
if condition…else…
Evaluate condition and perform either
IF condition …ELSE …
the first or the second code block
for condition…
Iteratively perform the next code block PERFORM paragraph
until condition is not true
VARYING
while condition…
Perform the next code block, until
PERFORM paragraph UNTIL
condition is not true
do…while
Perform the next code block, evaluate
PERFORM paragraph UNTIL
condition, and if true, perform code
condition
block again
switch (i) case…
Perform the appropriate code block
EVALUATE
depending on the value of (i)
case…
break
Exit the current loop
EXIT
continue
Reiterate the current loop from
the beginning
labeled break
Exit the loop with this name.
GO TO
The statement past the labeled loop
will be the next statement executed.
E XERCISES : F LOW C ONTROL
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. Remove the lines after the if statement where you tested the
value of textMsg .
2. First, you need to adjust the if code block in order to explore the scope of
local variables. After the if statement where you tested the value of
textMsg , add these additional bolded Java statements:
 
Search WWH ::




Custom Search