Upward transformation of Inner Class
When an Inner Class object is turned upward into interface, we get just a reference.
Interface destination {
String readlabel ();
}
Interface contents {
Int value ();
}
Class pacel3 {
Private
Class PContents
Implements contents {
Private
INT i = 11;
public
Int value () {
Return I;
}
protected
Class PDestination
Implements destination {
PRIVATE STRING LABEL;
PDestination (String WHereto) {
Label = WHERETO;
}
Public string readlabel () {
Return label;}
}
Public Destination to (String s) {
Return
New pdestination (s);
}
Public contents last () {
Return
New PContents ();
}
}
public
Class expectitstatic {
public
Static
Void main (string [] args) {
PARCEL3 P =
New paracel3 ();
// Transform the Inner Class object upward
CONTENTS C = P.cont ();
Destination D = P.to (
"Borneo");
}
}
Although we can't call PContents Class in the ExplicitStatic Class, we can call a PContents Class object to Contents to CONTENTS.