Should Java classes call super() when they have no parent class? [duplicate]

天涯浪子 提交于 2020-01-04 05:53:08

问题


Is it necessary or good practice to call super() when you're class only has Object as a parent?

i.e.

public class Foo {
  public Foo() {
    super();

    // Other stuff
  }
}

or

public class Foo {
  public Foo() {
    // Other stuff
  }
}

回答1:


No. It's implicitly invoked, so theres no reason to call it.



来源:https://stackoverflow.com/questions/24308447/should-java-classes-call-super-when-they-have-no-parent-class

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!