不知道是不是你说的意思,楼主应该自己写个例子验证一下哦!
- public class InnerClass {
- public static void main(String[] args) {
- // new TestClass().new Inner().show();
- new TestClass().new Inner2().test();
- }
- }
- class TestClass extends OuterClass {
- public class Inner2 extends OuterClass.Inner {
- public void test() {
- System.out.println("x = " + x);
- }
- }
- }
- class OuterClass {
- public class Inner {
- public int x = 3;
- public void show() {
- System.out.println("x = " + x);
- }
- }
- }
复制代码 |