[java]继承--构造方法

来源:互联网 发布:泰安广电网络 编辑:程序博客网 时间:2024/05/29 16:13

继承--构造方法

1,

父空参

子空参

2.

父空参

子空参

---public class Fu {    public Fu() {        System.out.println("fu gouzao");    }    public Fu(int i) {        System.out.println("fu youcan");    }}---public class Zi extends Fu {    public Zi() {        System.out.println("zi show");    }    public Zi(int i) {        System.out.println("zi youcan");    }}---public class Test {    public static void main(String[] args) {        new Zi(10); //走的父空构造,子有参构造    }}------