Java_继承中构造函数的应用
class Person { private String name; private int age; Person(String name,int age) { this.name=name; this.age=age; } public void setName(String name) { this.name=name; } public String getName() { return name; } public void setAge(int age) { this.age=age; } public int getAge() { return age; } } class Student extends Person { Student(String name,int age) { super(name,age); } } class Woker extends Person { Woker(String name,int age) { super(name,age); } } class ExtendsDemo5 { public static void main(String[] args) { Student stu = new Student("xiaoming",16); System.out.println(stu.getName()); System.out.println(stu.getAge()); } }