Do we inherit from Object?

后端 未结 3 1896
伪装坚强ぢ
伪装坚强ぢ 2021-01-18 19:30

Guys do we inherit from Object like from any other class (except of course that we don\'t have to explicitly state that) or there is some special privileges to Object class

3条回答
  •  一生所求
    2021-01-18 20:07

    No it's the same. Here the excerpt from JLS 8.1.3:

    If the class declaration for any other class has no extends clause, then the class has the class Object as its implicit direct superclass.

    Of course, Object itself is a bit special (JLS):

    Each class except Object is an extension of (that is, a subclass of) a single existing class (§8.1.3) and may implement interfaces (§8.1.4).

提交回复
热议问题