版权声明:本文为博主原创文章,转载请注明原博客地址。 https://blog.csdn.net/u012210441/article/details/51926631
interface Contents{
int value();
}
interface Destination{
String readLabel();
}
public class Parcel3 {
public Destination dest(String s){
class PDestination implements Destination{
private String label;
private PDestination(String whereTo){
label = whereTo;
}
public String readLabel(){
return label;
}
}
return new PDestination(s);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Parcel3 p = new Parcel3();
Destination d = p.dest("lalala");
System.out.println(d.readLabel());
}
}
上例中PDestination类即是方法dest中的内部类。