原文是这样写滴:
What Is an Interface? 
This section shows you how to create and to use interfaces and talks about why you would use an interface instead of a class. 
An interface defines a protocol of behavior that can be implemented by any class anywhere in the class hierarchy. An interface defines a set of methods but does not implement them. A class that implements the interface agrees to implement all the methods defined in the interface, thereby agreeing to certain behavior. --------------------------------------------------------------------------------
Definition: An interface is a named collection of method definitions (without implementations). An interface can also declare constants. 
--------------------------------------------------------------------------------
Because an interface is simply a list of unimplemented, and therefore abstract, methods, you might wonder how an interface differs from an abstract class. The differences are significant. 
An interface cannot implement any methods, whereas an abstract class can. 
A class can implement many interfaces but can have only one superclass. 
An interface is not part of the class hierarchy. Unrelated classes can implement the same interface. 
Let's set up the example we'll be using in this section. Suppose that you have written a class that can watch stock prices coming over a data feed. This class allows other classes to register to be notified when the value of a particular stock changes. First, your class, which we'll call StockMonitor, would implement a method that lets other objects register for notification:
public class StockMonitor {
     public void watchStock(StockWatcher watcher,
     String tickerSymbol, double delta) {
     ...
     }
}The first argument to this method is a StockWatcher object. StockWatcher is the name of an interface whose code you will see in the next section. That interface declares one method: valueChanged. An object that wants to be notified of stock changes must be an instance of a class that implements this interface and thus implements the valueChanged method. The other two arguments provide the symbol of the stock to watch and the amount of change that the watcher considers interesting enough to be notified of. When the StockMonitor class detects an interesting change, it calls the valueChanged method of the watcher. The watchStock method ensures, through the data type of its first argument, that all registered objects implement the valueChanged method. It makes sense to use an interface data type here because it matters only that registrants implement a particular method. If StockMonitor had used a class name as the data type, that would artificially force a class relationship on its users. Because a class can have only one superclass, it would also limit what type of objects can use this service. By using an interface, the registered objects class could be anything--Applet or Thread--for instance, thus allowing any class anywhere in the class hierarchy to use this service.

解决方案 »

  1.   

    JAVA中提供接口的目的是为了将定义和实现分离
    接口中没有任何实现
      

  2.   

    To:fireflyqt(孤独萤火虫)一、若A.class文件中的一个类(或者说是对象)实现了一个接口,那么在B.class中如何访问这个接口?如何访问?二、java类实现的接口,用别的语言编写的程序(二进制状态)能不能访问这个接口?对COM接口来说是可以这样得做的。三、若以上两点都无法实现的话,java中的接口意义不是很大。
      

  3.   

    JAVA中的接口和你所说的接口不是一个概念
    它应该算是语言的一个特性
    抽象类,你应该比较清楚,其中有部分实现
    而接口中没有任何实现,而实现该接口的具体类中必须对这些方法进行实现
    这样在程序中不知道会调用该接口的哪个实现类时,仍然可以正常编写程序
    而且日后扩充程序的内容,多加几个实现类,仍然不需要修改其他地方
    也就是满足“开-闭原则”
      

  4.   

    java接口机制解决类之间的通信
      

  5.   

    这么说,java的接口是源码级别的
      

  6.   

    com 基于idl所以是二进制级别的。java只能是源码级别的
      

  7.   

    java中的类不能多重继承,接口是解决的方式
      

  8.   

    同意  SStallMan(手起刀落) 当一个类无法继承多个类的时候,就可以来实现他们的多个接口