子类 /**
*子类
*/
public class Zi extends Fu {
public Zi() {
super();//提醒你你不写的他会自动提供
}
public Zi(String name, int age){
//调用父类的构造方法,初始化父类的属性
super(name, age);
}
}
测试 /**
*测试类
*/
public class Test {
public static void main(String[] args) {
Zi zi1 = new Zi();
Zi zi2 = new Zi("张三",12);
System.out.println(zi1.getName());
System.out.println(zi2.getName());