- <blockquote>package com.debug;
复制代码 结果是
Outer....show
Inner....run
Outer....show
ZiInner.........run- class Outter
- {
-
- public void show()
- {
- System.out.println("Outer....show");
- }
- class Inner
- {
- public void run()
- {
- System.out.println("Inner....run");
- }
- }
- }
- class Zi extends Outter
- {
-
-
- class Inner
- {
-
- }
-
-
- }
- class YanZhengInner
- {
- public static void main(String[] args)
- {
- new Outter().show();
- new Outter().new Inner().run();
- new Zi().show();
- new Zi().new Inner().run();
-
- }
- }
复制代码 结果是:
编译失败。Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method run() is undefined for the type Zi.Inner
at com.debug.YanZhengInner.main(YanZhengInner.java:37)
结论是:
子类可以继承外部类成员,但是不能继承内部类成员。想要有同样功能必须自己写,但是不能说是复写。
|