Java Reference
In-Depth Information
changes to the design as you proceed through implementation. This is characteristic
of the iterative nature of object-oriented programming: the ability to go back and
make continual refinements. Be careful, however, to stay within the scope of the
original project and make such refinements only when clearly warranted.
Starting a New Java Program in TextPad
The following steps start TextPad and save the TextPad document using a
Java file type.
To Start a New Java Program in TextPad
1. Insert the Data Disk in drive A.
2. Start TextPad. If necessary, click View on the menu bar and then click
Line Numbers on the View menu to display line numbers.
3. Click File on the menu bar and then click Save As on the File menu.
When the Save As dialog box is displayed, click the Save in box arrow
and then click 3 1 / 2 Floppy (A:) in the Save in list.
4. Double-click the Chapter09 folder or a location specified by your
instructor.
5. Type Password in the File name text box and then click Java (*.java)
in the Save as type list. Click the Save button.
The file named, Password, is saved as a Java source code file in the
Chapter09 folder on the Data Disk in drive A (Figure 9-4).
file saved as
Password.java
FIGURE 9-4
Class, Instance, and Final Variables
The requirements document in Figure 9-2 on page 541 indicates that some attrib-
utes of the Password class apply equally to all instances of the class, effectively
sharing the variables among objects, while other attributes have unique values for
each instance. This indicates a need for both class and instance variables.
Understanding Class and Instance Variables
A class variable is a variable shared by all objects of a class — that is, all
instances. A class variable has only one value regardless of the particular object
using it. If its value is changed for one object, then it is changed for all objects.
 
Search WWH ::




Custom Search