OnJava8-Examples/innerclasses/TestParcel.java

35 lines
871 B
Java
Raw Normal View History

2015-04-20 15:36:01 -07:00
//: innerclasses/TestParcel.java
2015-05-29 14:18:51 -07:00
// <20>2015 MindView LLC: see Copyright.txt
2015-04-20 15:36:01 -07:00
class Parcel4 {
private class PContents implements Contents {
private int i = 11;
2015-05-05 11:20:13 -07:00
@Override
2015-04-20 15:36:01 -07:00
public int value() { return i; }
}
protected class PDestination implements Destination {
private String label;
private PDestination(String whereTo) {
label = whereTo;
}
2015-05-05 11:20:13 -07:00
@Override
2015-04-20 15:36:01 -07:00
public String readLabel() { return label; }
}
public Destination destination(String s) {
return new PDestination(s);
}
public Contents contents() {
return new PContents();
}
}
public class TestParcel {
public static void main(String[] args) {
Parcel4 p = new Parcel4();
Contents c = p.contents();
Destination d = p.destination("Tasmania");
// Illegal -- can't access private class:
//! Parcel4.PContents pc = p.new PContents();
}
} ///:~