Is usage of anonymous classes in Java considered bad style or good?

后端 未结 14 1286
Happy的楠姐
Happy的楠姐 2020-12-05 01:58

I know anonymous classes save typing when it comes to implementing Listener and similar stuff. They try to be a replacement for some usages of closures.

But what doe

14条回答
  •  误落风尘
    2020-12-05 02:49

    There is nothing inherently different or special about anonymous classes. They are ultimately just syntactical sugar with support for referencing the outer class. This makes it easier to author adapters - just like most of the Iterator implementations returned by the Collections framework.

提交回复
热议问题