Java中内部类的用途是什么?嵌套类和内部类是一样的吗? [英] What are the uses of inner classes in Java? Are nested classes and inner classes the same?

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

问题描述


可能重复:

Java内部类和静态嵌套类

Java中内部类的用途是什么?嵌套类和内部类是否相同?

What are the uses of inner classes in Java? Are nested classes and inner classes the same?

推荐答案

不,它们不一样:内部类是非 static

No, they're not the same: an inner class is non-static.


JLS 8.1.3内部类和附件实例



内部类是一个嵌套类,未显式或隐式声明为静态。

JLS 8.1.3 Inner Classes and Enclosing Instances

An inner class is a nested class that is not explicitly or implicitly declared static.

另请参阅Joe Darcy的下图:

Consult also the following diagram from Joe Darcy:




Joseph D. Darcy's Oracle Weblog - Nested, Inner, Member, and Top-Level Classes






相关问题




  • Java内部类和静态嵌套类


  • Related questions

    • Java inner class and static nested class
    • 这篇关于Java中内部类的用途是什么?嵌套类和内部类是一样的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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