package java_learning;
public class super_test {
public static void main(String[] args){
Dog Obj = new Dog(1,"你好");
Obj.Move();
}
}
class Animal{
//private String m_str = "this is a father class of animal!";
public String m_str = "this is a father class of animal!";
public String GetString(){
return m_str;
}
public void Move(){
System.out.println("animals can move");
}
Animal(String str){
this.m_str = str;
}
}
class Dog extends Animal{
int age;
public Dog(int i, String str){
super(str);//调用父类的构造方法
this.age = i;
}
public void Move(){
super.Move();
System.out.println("Dog Can walk and run");
System.out.println("please remember that:"+super.GetString());
System.out.println("please remember that:"+super.m_str);
//super("dog");
}
}
super_test
最新推荐文章于 2024-03-17 09:44:35 发布