Java里只能单重继承,不能多重继承的。作为弥补,创造了接口这个概念。

解决方案 »

  1.   

    http://www.csdn.net/Expert/topic/432/432882.shtm
      

  2.   

    Anwser for I:  if you have an existed class, however, you want to make it to belong to another new type.  You can create a new subclass which extends the existed class(reuse) and implements the new interface type.  Therefore, this new interface help you create a new TYPE.  You can understand this better when you touch some patterns of OOP.
      

  3.   

    你的猜想差不多是对的,不过java的多重继承好像跟c++的不大一样不过你那样说也可以,因为目的达到了
      

  4.   

    if you have some idea about design pattern, such as Factory & Abstract Factory, it is good for you to understand interface.interface is very useful, when you need special method for the object, and the type of object is not sure. 
      

  5.   

    if you have class A B implements interface C.There is no relationship between A and B.the following codes is useful.C variableName1 = new A();
    C variableName2 = new B();or sometimes you can cast the Object to speical interface typeInterfaceName variableName1 = InterfaceName(Vector.get());
      

  6.   

    By the way, Java is based on Single inheritance (SmallTalk) rather than multiple inheritance (C++).
      

  7.   

    我认为,java中的接口有以下优点:一 用于实现类似于C++中的多继承,改用interface实现,解决了多继承可能出现的
    一些问题。二 保持继承树的清晰明朗,给后续子类提供一个统一的,抽象层次较高的公用类型。
    基于此可以实现更为清晰的多态。三 可以用来实现类似C++,delphi等语言中callback的功能。如果你对AWT实践模型
    比较清楚,那么你应该明白interface在java中有多重要。其实在这时候,interface
    实际上就充当了C++/delphi里面的函数/过程 指针。四 在软件工程方面,设计与实现分离,更容易编写和维护代码。你可以简单看一些例子,比如:定时器的实现,事件监听接口,钩子等
    COM里面的一些例子也可以说明interface的好处。
      

  8.   

    http://www.csdn.net/Expert/topic/427/427844.shtm
    关于interface和C++的多继承,我认为没有任何关系。正如cc9hwa(rubbish)说的,这两个不同门不同路的东西,有什么好比较的。
    dcren(稻草人)的三四点比较有理。