super中怎么调用父类的有参构造方法?
//父类——动物
Public class Animal{
public int age = 10;
public String name;
public void eat(){
System.out.println("动物具有吃东西的能力");
}
public Animal(int age){
this.age = age;
System.out.println("Animal类构造方法执行了");
}
}
//子类——狗
public class Dog extends Animal{
public int age =20;
public void eat(){
System.out.println("狗具有吃骨头的能力");
}
public Dog(int age){
super(age);//显式调用父类(动物)的有参数构造方法
System.out.println("Dog类构造方法执行了")
}
}
super(参数列表);