父类内部类是静态的也可以覆盖。- class OuterClass1
- {
- private int a = 10;
- static class Inner
- {
- private int a = 20;
- private int b = 5;
- void one(){
- System.out.println(b);
- System.out.println(a);
- System.out.println(this.a);
- }
- }
- void test(){
- Inner i = new Inner();
- i.one();
- }
- }
- class OuterClass2 extends OuterClass1
- {
- static int b = 100;
- static class Inner
- {
- void one(){
-
- System.out.println("b = "+ b);
- }
- }
- void test(){
- //Inner i = new Inner();
- new Inner().one();
- }
- }
- class TestInner{
- public static void main(String[] args){
- new OuterClass2().test();
- new OuterClass().test();
- //OuterClass.Inner i = new OuterClass().new Inner();
- //i.one();
- //OuterClass.Inner i = new OuterClass.Inner();
-
- //i.one();
- }
- }
-
复制代码 |