So we all know that all classes implicitly extend Object. How about interfaces? Is there an implicit super-interface? I say there is. The following code compiles:
java.io.Serializable s1 = null;
java.io.Serializable s2 = null;
s1.equals(s2);
The equals
method is not declared in Serializable, but in Object. Since interfaces can only extend other interfaces, and Object is a class, not an interface, there must be some implicit interface that is being extended. And the Object
class must then implicitly implement this implicit interface (wow, that was weird to write).
So, the question is, how correct is this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…