Java Reference
In-Depth Information
The following step enters code to close the program.
To Enter Code to Close the Program
1. Click at the end of line 34. Press the ENTER key twice. Type
System.exit(0); as the new code.
The code for the System.exit() method is entered (Figure 3-32).
System.exit()
method
added
FIGURE 3-32
The Swing version of the program now is complete. The code shown
in Figure 3-32 includes a new import statement; the new class name,
BodyMassSwing; and has no unnecessary code. It also includes code to
prompt the user and to accept a String answer using dialog boxes. Finally, the
code includes a System.exit() method, so that the program will terminate
properly.
Once the code is complete, check for syntax, proper spelling, capitalization,
and indentations. When you are confident everything is correct, you are ready to
save and compile your program.
Search WWH ::




Custom Search