// : c08:Parcel1.java
// Creating inner classes.
// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
// www.BruceEckel.com. See copyright notice in CopyRight.txt.
publicclass Parcel1 {
class Contents {
privateint i = 11;
publicint value() {
return i;
}
}
class Destination {
private String label;
Destination(String whereTo) {
label = whereTo;
}
String readLabel() {
return label;
}
}
// Using inner classes looks just like
// using any other class, within Parcel1:
publicvoid ship(String dest) {
Contents c = new Contents();
Destination d = new Destination(dest);
System.out.println(d.readLabel());
}
publicstaticvoid main(String[] args) {
Parcel1 p = new Parcel1();
p.ship("Tanzania");
}
} ///:~