June 2017
Beginner
1296 pages
69h 23m
English
... files—PackageDataTest.class and PackageData.class. The compiler places the two .class files in the same directory. You can also place class PackageData (lines 22–30) in a separate source-code file.
1 // Fig. 8.15: PackageDataTest.java
2 // Package-access members of a class are accessible by other classes
3 // in the same package.
4
5 public class PackageDataTest {
6 public static void main(String[] args) {
7 PackageData packageData = new PackageData();
8
9 // output String representation of packageData
10 System.out.printf("After instantiation:%n%s%n", packageData);
11
12 // change package access data in packageData object
13 packageData.number = 77;
14 packageData.string = "Goodbye";
15
16 // output String representation of packageData ...Read now
Unlock full access