1.关于继承
class One {
public One(){
System.out.println("首先,One的无参构造方法被引用");
}
public void Str(){
System.out.println("在b.Str()处,因为Two有自己定义Str方法,所以没有调用父类One的Str方法");
}
}
class Two extends One{
public Two(int x){
System.out.println("再者,调用Two的有参构造方法\t"+"传入的值为:"+x);
}
public void Str(){
System.out.println("最后,调用了Two的Str方法");
}
}
public class Three {
public static void main(String args[]){
Two b=new Two(6);
b.Str();
System.out.println("\n");
One e=new One();
e.Str();
}
}