Java 调用父类构造方法


Java 调用父类构造方法

class Superclass {
   int age;

   Superclass(int age) {
      this.age = age;        
   }

   public void getAge() {
      System.out.println("The value of the variable named age in super class is: " +age);
   }
}

public class Subclass extends Superclass {
   Subclass(int age) {
      super(age);
   }

   public static void main(String argd[]) {
      Subclass s = new Subclass(24);
      s.getAge();
   }
}