Advantage of Local Classes Java

后端 未结 3 1083
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 03:33

What is the advantage of local classes in Java or in any other language that makes use of this feature?

3条回答
  •  情话喂你
    2020-11-29 04:16

    They allow you to take logic out of the parent class and objectify it. This removes functionality from where it doesn't belong and puts it into its own class. But what if this new object is only needed for a short time, only for the duration of a single block of code? Well, that's where a local class fits in.

提交回复
热议问题