复制代码
- //:Parcel3.java
- //Returningahandletoaninnerclass
- packagec07.parcel3;
- abstractclassContents{
- abstractpublicintvalue();
- }
- interfaceDestination{
- StringreadLabel();
- }
- publicclassParcel3{
- privateclassPContentsextendsContents{
- privateinti=11;
- publicintvalue(){returni;}
- }
- protectedclassPDestination
- implementsDestination{
- privateStringlabel;
- privatePDestination(StringwhereTo){
- label=whereTo;
- }
- publicStringreadLabel(){returnlabel;}
- }
- publicDestinationdest(Strings){
- returnnewPDestination(s);
- }
- publicContentscont(){
- returnnewPContents();
- }
- }
- classTest{
- publicstaticvoidmain(String[]args){
- Parcel3p=newParcel3();
- Contentsc=p.cont();
- Destinationd=p.dest("Tanzania");
- //Illegal--cantaccessprivateclass:
- //!Parcel3.PContentsc=p.newPContents();
- }
- }///:~
欢迎光临 仓酷云 (http://ckuyun.com/) | Powered by Discuz! X3.2 |