Java Reference
In-Depth Information
Editing a Class Name and Saving a File with a New File Name
The program coded in the Sample2.java file asks the user for his or her name and then prints a
message in the Command Prompt window. Its purpose is not to show any new coding techniques, but
to illustrate how to create program documentation in HTML format.
Before editing an existing file that you may want to use again, it is a good idea to save the file with
a different name. Recall that in Java, the class name must match the file name. The following steps edit
the class name and then save the Sample2.java file with a new name.
To Edit a Class Name and Save a File with a New File Name
1. With the Sample2.java source code displaying in the coding window, change the file name in
line 5 to SampleJavadoc.java. Change the class name in line 11 to SampleJavadoc.
2. Click File on the menu bar and then click Save As on the File menu. When the Save As dialog
box is displayed, if necessary, click the Save in box arrow and then click 3 1 2 Floppy (A:) in the
Save in list. Double-click the Appendices folder or a location specified by your instructor.
3. Type SampleJavadoc in the File name text box and then, if necessary, click Java (*.java) in the
Save as type list.
The Save As dialog box displays the new file name in the File name text box (Figure E-3). The com-
ments and class name have been edited to reflect the new file name.
new file name
in comment
new class name
Save As
dialog box
Appendices
folder
new file
name
Save
button
file type
FIGURE E-3
4. Click the Save button in the Save As dialog box.
 
Search WWH ::




Custom Search