Why does adding a public field to an anonymous class in Java not work?

后端 未结 8 1607
渐次进展
渐次进展 2020-12-17 15:48

I have an example class defined like below:

public class FooBar {

  void method1(Foo foo){ // Should be overwritten
    ...
  }

}

Later,

8条回答
  •  臣服心动
    2020-12-17 16:27

    fooBar type is foobar which has not such variable and therefore the code can not be compiled. You can access it by reflection.

提交回复
热议问题