好多书或网上帖子说到这个的时候都说是为了实现多继承
既然接口里什么都不实现,我用它还要自己来实现它,那要它何用??我自己在类里定义这些方法就行了??这个"继承"和不"继承"有什么区别??
难道只是为了强调出接口中的方法只是"外来的",不是类本身的方法这个作用??
有用过它,对它有体会的人来告诉我答案吗,它真正的好处是在哪里

解决方案 »

  1.   

    class a中如果实现了interface i的方法,那么i中的这些方法应该不算是a中的成员吧
    如果b继承了a,b不继承其中i里的这些方法吧,不知道我的理解对不对
      

  2.   

    Interface looks like a contract, if you implement it. Because you have to implement all the methods defined in the interface, so as to avoid compiler error. 
      

  3.   

    For example: the interface: Comparable. If you write a class implement this interface, you can sort it convenient.More details, please refer to:
    http://blog.csdn.net/justinavril/archive/2008/09/13/2924557.aspx
      

  4.   

    比如interface a, interface  b,你可以 interface  c extends a,b所以可以多继承了
    呵呵
      

  5.   

    定义功能啊,比较抽象,让所有实现该接口的类有相同的行为 就这样heh