Accessing inner anonymous class members

后端 未结 7 1771
灰色年华
灰色年华 2021-01-05 18:00

Is there any way other than using reflection to access the members of a anonymous inner class?

7条回答
  •  囚心锁ツ
    2021-01-05 18:31

    Mr Fooz is right, except that interfaces can only define constant members. the best way would be to add getter/setter methods to your interface and then use those to get your value. but then for each anonymous class you would have to define those methods (kind of a pain).

提交回复
热议问题