Java Reference
In-Depth Information
The Password class requires two changes to the source code, as shown in
Figure 11-4 on page 700. Because Serializable is an interface, the class definition
must be modified to implement it. In order for the compiler to locate the inter-
face definition, however, Password.java must import the java.io package. The fol-
lowing steps implement the Serializable interface in the Password class.
To Implement the Serializable Interface
1. Insert line 10 as shown in Figure 11-4 on page 700. In the comments,
insert your own name as programmer, if necessary, and enter the
current date.
TextPad displays the beginning lines of code for the Password class, includ-
ing the initial comments and the import statements, in the coding window
(Figure 11-6).
comments
updated
import
statement
inserted
FIGURE 11-6
2. Modify the class header line as shown on line 12 in Figure 11-4. Save
and compile the changes.
TextPad displays the code for the Password class header which now imple-
ments the Serializable interface (Figure 11-7).
code added
to class header
FIGURE 11-7
 
Search WWH ::




Custom Search