Enclosing Class

is not a enclosing class .. 今天又碰到这个错误了,正好有空仔细查了一下。
不是一个封闭类(外部类)

enclosing class ,是相对于 nested class 来说的。non-static nested class 可以访问其enclosing class (外部类)的成员。

那么其实还有一个 inner class 的概念。见:http://www.cnblogs.com/aigongsi/archive/2012/04/24/2467183.html

查了一下:http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html
原来 inner class (内部类)和nested class (嵌套类) 的区别是这样:
Terminology: Nested classes are divided into two categories: static and non-static. Nested classes that are declared static are called static nested classes. Non-static nested classes are called inner classes.

nested class 包含了 inner class,是他的超集。 其中 non-static nested class ==inner class 。

因此碰到这个is not a enclosing class .. ,要么用外部类,要么内部类定义为静态。
记录一下~

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容