实际上在Sun的官方文档TJLS(The Java Language Specification)就有相关说明:
其中第9章9.2节关于接口有这么一段话:
If an interface has no direct superinterfaces, then the interface implicitly declares a public abstract member method m with signature s, return type r, and throws clause t corresponding to each public instance method m with signature s, return type r, and throws clause t declared in Object, unless a method with the same signature, same return type, and a compatible throws clause is explicitly declared by the interface.
它大概意思是说当一个接口没有直接extends superinterfaces时,那么再该接口中就会隐含定义了一套与Object类中的方法签名完全相同的方法,所以,我们在程序中调用接口的那些与Object中具有相同签名的方法时,编译器不会报错!
|