[TIJ3]Chap08_1133中的一句话so implementing a private interface is a way to force the definition of the methods in that interface without adding any type information (that is, without allowing any upcasting). 直译过来就是:实现一个private接口是这样一种方式:它强制在该接口中定义的方法不能够添加类型信息(就是说,不允许向上转型)不理解什么叫“添加类型信息”?

解决方案 »

  1.   

    翻译错了。
    应该是:
    实现一个私有接口是这样一种方式:它强制定义那个接口的方法,但不添加任何类型信息(也就是说,不允许任何向上转型)。解释应该是不会在实现这个接口的类中增加任何的向上转型。private interface a {
     void a1();
    }public class b implements a {
     public void a1() {};
    }//类似 (a)b 这样的转换不能实现
      

  2.   

    就是说没有为这个类添加在别的类中可以使用的接口。比如上边的b类,虽然实现了a接口,仍然只有Object一个基类可以让其他的类使用,而接口a对于其他类来说等于没有添加到b类中。