Calling super()

后端 未结 12 1064
孤独总比滥情好
孤独总比滥情好 2020-12-01 12:24

When do you call super() in Java? I see it in some constructors of the derived class, but isn\'t the constructors for each of the parent class called automatically? Why woul

12条回答
  •  借酒劲吻你
    2020-12-01 12:41

    You may call super() with parameters if you want to call a non-default constructor of the superclass, or if the superclass does not have a default constructor. The compiler can only insert the default, no arguments super() constructor.

提交回复
热议问题