super() in Java

前端 未结 15 2292
逝去的感伤
逝去的感伤 2020-11-22 05:36

Is super() used to call the parent constructor? Please explain super().

15条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 05:50

    super is a keyword. It is used inside a sub-class method definition to call a method defined in the superclass. Private methods of the superclass cannot be called. Only public and protected methods can be called by the super keyword. It is also used by class constructors to invoke constructors of its parent class.

    Check here for further explanation.

提交回复
热议问题