Java Object superclass

前端 未结 3 1034
长发绾君心
长发绾君心 2021-01-11 12:10

I have a weird Java question:

As we know:

  1. All Java classes extend java.lang.Object
  2. All Java classes cannot extend itself
3条回答
  •  轮回少年
    2021-01-11 12:18

    Object does not extend itself. It is the superclass for all other objects in the Java language. Think of it as being the level-0 (or root) class of all the objects in the Java API tree - including any objects you create as well.

    I also just want to point out that your question is proven impossible by rule #2 that you posted. Your logic used to justify your question only takes #1 into account and is therefore extremely flawed.

提交回复
热议问题