为什么我分开来编译出错,合起来就行?
package c07.innerscopes;interface Destination {
  String readLabel();
}
//
package c07.innerscopes;public class Parcel4 {
  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) {
    Parcel4 p = new Parcel4();
    Destination d = p.dest("Mtan");
  }
}

解决方案 »

  1.   

    分开编译时,先编译Destination,再编译Parcel4,注意编译Parcel4 时把Destination放在类路径里
      

  2.   

    是在classpath中加上 F:\MyDel\c07\innerscopes\Destination.class;?
      

  3.   

    那倒不用加上classpath的内容。。
    只要你在F:\MyDel\c07\innerscopes\ 这个路径下编译 跟执行就应该没问题。。
    而分开编译与合在一起编译产生的问题,二楼的朋友说得也很正确了~
      

  4.   

    分开时先要有Destination.class才行
      

  5.   

    在classpath中加上 F:\MyDel\c07\innerscopes\Destination.class
    即是:
    javac -classpath F:\MyDel\c07\innerscopes\ Parcel4.java
      

  6.   

    thinking in java里面的程序.^_^,楼主看书不仔细呀!