Java Reference
In-Depth Information
This project puts the finishing touches on the Java help system that was created in the pre-
vious projects. This version adds the syntax for
break
and
continue
. It also allows the user
to request the syntax for more than one statement. It does this by adding an outer loop that
runs until the user enters
q
as a menu selection.
1.
Copy
Help2.java
to a new file called
Help3.java
.
2.
Surround all of the program code with an infinite
for
loop. Break out of this loop, us-
ing
break
, when a letter
q
is entered. Since this loop surrounds all of the program
code, breaking out of this loop causes the program to terminate.
3.
Change the menu loop as shown here:
Notice that this loop now includes the
break
and
continue
statements. It also accepts
the letter
q
as a valid choice.
4.
Expand the
switch
statement to include the
break
and
continue
statements, as shown
here: