Implicit super interface in Java?

So we all know that all classes implicitly extend object How about the interface? Is there an implicit super interface? I said yes The following code is compiled:

java.io.Serializable s1 = null;
java.io.Serializable s2 = null;

s1.equals(s2);

The equals method is not declared in serializable, but in object Because interfaces can only extend other interfaces, and object is a class, not an interface, there must be some implicit interfaces being extended Then, the object class must implicitly implement the implicit interface (Wow, it's strange to write)

So the question is, how right is this?

Solution

Reference Java language specification:

The difference between this and your "implicit super interface" is that object has many final and protected methods. You can't have these modifiers in the interface

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>