[java]继承--构造方法
程序员文章站
2022-05-14 11:57:56
...
继承--构造方法
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); //走的父空构造,子有参构造
}
}
------
上一篇: 自己前几天写的无限分类类