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

查看:18
本文介绍了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天全站免登陆