java enclose class_Enclosing Class

is not a enclosing class .. 今天又碰到这个错误了,正好有空仔细查了一下。

不是一个封闭类(外部类)

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

查了一下: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 .. ,要么用外部类,要么内部类定义为静态。

记录一下~

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值