内部类.目的是什么? [英] Inner Class. What is its purpose?

查看:81
本文介绍了内部类.目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我开设内部类课程的目的是什么?我可以想到一些,但也许它们不是使用内部类的充分理由.我的理由是,当您要使用其他任何类都无法使用的类时,内部类会很有用.还有什么?

Can someone tell me what the purpose of having inner classes? I can think of a few but may be they are not good reasons for using inner classes. My reasoning is that inner class is helpful when you want to use a class that no other classes can use. What else?

推荐答案

内部类可用于模拟闭包: http://en.wikipedia.org/wiki/Closure_(computer_science)#Java

Inner classes can be used to simulate closures: http://en.wikipedia.org/wiki/Closure_(computer_science)#Java

这篇关于内部类.目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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