implicit super-interface in Java?

后端 未结 4 2043
情歌与酒
情歌与酒 2020-12-11 22:04

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:

         


        
4条回答
  •  渐次进展
    2020-12-11 22:54

    I don't think there's any super interface.

    When you declare a variable like this:

    java.io.Serializable s1 = null;
    

    you haven't created any Object.

    The compiler knows that s1 and s2 will implement Serializable and will descend from Object so it allows the equals.

提交回复
热议问题