假设现在有这么一个父类:
public class Person{
public Person(){}
public String name = "tom";
public int age = 1;
public int sex = 0;
public void showInfo(){
System.out.println(this.name);
System.out.println(this.age);
System.out.println(this.sex);
}
public void seInfo(String name, int age, int sex){
this.name = name;
this.age = age;
this.sex = sex;
}
}
有一个子类:
public class Student extends Person{
public Student(){
super();
}
public String school;
}
那么进行Student stu = new Student();的过程如下: