class Student{
int number;String name;
Student(){ //不带参数的构造方法防止子类省略super时出现错误
}
Student(int number,String name){
this.number=number; //this表示某个对象,调用该方法的当前对象(调用类中的成员变量)
this.name=name;
System.out.println("number="+number+";name="+name);
}
}
class U_Student extends Student{ //继承父类
boolean mr;
U_Student(int number,String name,boolean b){
super(number,name); //调用父类中的构造方法(Student)
mr=b;
System.out.println("mr="+mr);
}
}
public class EXP12 {
//java程序入口
public static void main(String[] args) {
U_Student zw=new U_Student(123,"zw",true);
}
}