✔ 最佳答案
Interface 其實指一個abstract class,內裡只有static variable 和 function 的 declaration,而沒有function implementation,以及instance variables。如:
Interface anInterface {
static public final int CONST = 4;
int aMethod();
}
要使用的話,就要像以下的作法:
public class aClass implements anInterface {
int aMethod() { return; }
}
Interface 的出現,其實是為了要解決Multiple Inheritance 的問題。因Java 只限INherit from 一個class,要做到Multiple Inheritance的效果就要用Interface。
(以上…各位不明可以不理 XD)
Java 中有很多Interface,如Listener Interface 就是。