Outer vs. Super class

前端 未结 2 2015
暗喜
暗喜 2021-02-05 14:00

Does super has higher priority than outer class?

Consider we have three classes:

  1. ClassA
  2. ClassB
  3. Anonymous class in ClassB that extends Cla
2条回答
  •  隐瞒了意图╮
    2021-02-05 14:40

    I think you are always going to get "A var".

    This is because your test() method implementation is being defined on an anonymous subclass of A. I don't think you can access the B.var instance variable within your test() method unless you explicitly refer to the outer class using ClassB.this.var.

提交回复
热议问题