parent
public class Person {
private String name;
public Person(String name){
this.name=name;
}
public void setName(String name){
this.name=name;
}
public String getName(){
return this.name;
}
}
subclass
public class Student extends Person {
public Student(String name){
super(name);
}
public String print(){
return getName();
}
Who in the }
subclass is calling the getName () method, and is it the subclass object that is calling it? This can be understood as this.getName () no, and the this here represents the current object (that is, the subclass object) that calls the method. The getName () method here inherits the method of the parent class, so which object is represented by the this, in this.name in this method? Please.