有一个简单的程序,在构造函数中,super()被调用而没有扩展到超类,我无法理解在这种情况下会做什么呢?
public class Student {
private String name;
private int rollNum;
Student(String name,int rollNum){
super(); //I can not understand why super keyword here.
this.name=name;
this.rollNum=rollNum;
}
public static void main(String[] args) {
Student s1 = new Student("A",1);
Student s2 = new Student("A",1);
System.out.println(s1.equals(s2));
}
}
Run Code Online (Sandbox Code Playgroud)