Are anonymous classes a subset of inner class?

随声附和 提交于 2019-12-02 13:07:23

This is quite true. Your anonymus class could not be implemented outside of other classes, as a seperate class, because as it is anonymus you would not be even able to refer to it in any way.

Additional information: From JLS: An anonymous class is always an inner class (§8.1.3); it is never static (§8.1.1, §8.5.1).

Anonymous classes are types of inner classes. See http://docs.oracle.com/javase/tutorial/java/javaOO/innerclasses.html

Quoting from there:

"You can also declare an inner class within the body of a method without naming the class. These classes are known as anonymous classes."

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!