Why should I call super() in Java?

后端 未结 5 1137
青春惊慌失措
青春惊慌失措 2021-01-22 04:17

I see an example from a book that I read about java:

public class A{
  public A(){
      System.out.println(\"A\");
   }
}

public class B extends A{
    public          


        
5条回答
  •  清歌不尽
    2021-01-22 05:12

    super(); is redundant and unneeded. However sometimes you want to or must call a specific super class constructor. In those situations you would need to use it with the appropriate parameters: super( params );

提交回复
热议问题