Strange syntax for instantiating an inner class

前端 未结 6 1832
慢半拍i
慢半拍i 2020-12-05 09:12

I didn\'t imagine that I would encounter radically new syntax in Java anymore at this stage, but lo and behold, I just encountered something:

The exact context a

6条回答
  •  借酒劲吻你
    2020-12-05 10:07

    Button.ClickEvent is a non-static inner class so an instance of this class can only exist enclosed in a instance of Button.

    In your second code example you have an instance of Button and you create an instance of ClickEvent enclosed in this Button instance...

提交回复
热议问题