- public class DuoTai_3
- {
- /**
- * @param args
- */
- public static void main(String[] args)
- {
- Fu f = new Zi();
-
- f.method1();
- f.method2();
- //f.method3(); [color=Red]为什么这个调用不了?子类不是继承了父类的了么?[/color]
- f.method4();
-
-
- }
- }
- class Fu
- {
- static int num = 5;
- void method1()
- {
- System.out.println("fu method_1");
- }
- void method2()
- {
- System.out.println("fu method_2_"+num);
- }
- static void method4()
- {
- System.out.println("fu method_4");
- }
- }
- class Zi extends Fu
- {
- static int num = 8;
- void method1()
- {
- System.out.println("zi method_1_"+num);
- }
-
- void method3()
- {
- System.out.println("zi method_3");
- }
- static void method4()
- {
- System.out.println("zi method_4");
- }
- }
复制代码 |