本地类的优点Java [英] Advantage of Local Classes Java

查看:92
本文介绍了本地类的优点Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本地类在Java或使用此特性的任何其他语言的优势是什么?

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

推荐答案

允许你从父类中取出逻辑并将其对象化。这会从不属于它的地方删除功能,并将其放入自己的类中。但是,如果这个新对象只需要很短的时间,只有一段代码的持续时间呢?那么,这是一个本地类适合的地方。

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.

这篇关于本地类的优点Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆