public class Mother extends Thread{
String name;
public Mother(String name) {
this.name = name;
}
@Override
public void run() {
System.out.println("mother");
}
}
public class Son extends Mother{
String name;
public Son(String name) {super(name);this.name = name;}
@Override
public void run() {System.out.println(name);}
public void startup(){super.start();}}
public class Launch {
public static void main(String[] args) {
Mother mother = new Mother("mother");
Son son = new Son("son");
son.startup();
}
}
为什么打出了son???
我的startup()方法里调的是super.startup()啊
相关分类