Fu
package com.itheima;
public class Fu {
public void show(){
System.out.println("show方法被调用");
}
}
Zi
package com.itheima;
public class Zi extends Fu{
public void method(){
System.out.println("method方法被调用");
}
}
Demo
package com.itheima;
/*
测试类
*/
public class Demo {
public static void main(String[] args) {
//创建对象,调用方法
Fu f =new Fu();
f.show();
Zi z=new Zi();
z.method();
z.show();
}
}
运行结果: