class P {
class Contents{
private int i=11;
public int value(){return i;}
}
class Destination{
private String label;
Destination(String whereto){
label=whereto;
}
String readLabel(){return label;}
}
public void ship(String dest){
Contents c=new Contents();
Destination d=new Destination(dest);
System.out.println(d.readLabel());
}
public Destination to(String s) {
return new Destination(s);
}
public Contents cont(){
return new Contents();
}
public static void main(String[] args) {
P p=new P();
p.ship("sdfsdfsdf");
P q=new P();
P.Contents c=q.cont();
P.Destination d=q.to("78888");
}
}
这个程序中
public Destination to(String s) {
return new Destination(s);
}
public Contents cont(){
return new Contents();
}
这段声明to和cont方法是什么方法?为什么要声明? 前面为什么还要各跟一个Destination和Contents?请教各位高手,谢谢