- class ExtendsDemo5{
- public static void main(String[] args){
- Zi z = new Zi();
- z.show();
- }
- }
- class Fu{
- Fu(){
- show();
- }
- void show(){
- System.out.println("fu -- show");
- }
- }
- class Zi extends Fu{
- int num = 8;
- Zi(){
- super();
- System.out.println("coder---"+num);
- }
- void show(){
- System.out.println("zi -- show---"+num);
- }
- }
复制代码
为什么父类构造函数中调用的show方法是子类中复写的show方法呢? |
|