(^298) | Object-Oriented Software Design and Implementation
outFile.println(" Yes.");
else
outFile.println(" No.");
outFile.print("equal: Is firstPhone equal to thirdPhone? ");
if (firstPhone.equals(thirdPhone))
outFile.println(" Yes.");
else
outFile.println(" No.");
outFile.print("equal: Is firstPhone equal to fourthPhone? ");
if (firstPhone.equals(fourthPhone))
outFile.println(" Yes.");
else
outFile.println(" No.");
outFile.close();
}
}
We have a public class Phoneand a public class TestPhone, which includes several variables
of the class Phone. How do we get these two classes to interact? Until now, we have simply
put them in the same directory and had the driver import the class. We promised a better
way to do this; here it is. We declare the class Phoneto be in the package phoneand store it in
the file Phone.javain the directory phone. The class TestPhonethen imports the package phone.
That is, in the file Phone.javain the directory phone, we have
packagephone;
public classPhone { ... }
In the file TestPhone.java, we have
import phone.*;
public classTestPhone { ... }
Here is a copy of the file phoneOut:
やまだぃちぅ
(やまだぃちぅ)
#1