super keyword without extends to the super class

后端 未结 3 652
执笔经年
执笔经年 2020-12-03 23:09

There is a code of simple program. In constructor, super() is called without extends to the super class, I can not understand what will does this in this situat

3条回答
  •  無奈伤痛
    2020-12-03 23:43

    Every class that doesn't explicitly extend another class implicitly extends java.lang.Object. So super() simply calls the no-arg constructor of Object.

    Note that this explicit call is unnecessary since the compiler would add it for you. You only need to add a super() call in a constructor when you want to invoke a superclass constructor with arguments.

提交回复
热议问题