`
abc20899
  • 浏览: 909034 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Java编译错误“No enclosing instance of type

    博客分类:
  • java
 
阅读更多
Java编译错误“No enclosing instance of type AA is accessible. Must qualify the allocation with an enclosing instance of type SimpleTh


这是因为AA是一个动态的内部类,创建这样的对象必须有实例与之对应,程序是在静态方法中直接调用动态内部类会报这样错误。   这样的错误好比类中的静态方法不能直接调用动态方法。可以把该内部类声明为static。或者不要在静态方法中调用。

那么为啥非静态方法不能调用动态方法呢,从面向对象的角度来说,动态方法与对象是联系密切的,比如发动是一个方法,它与汽车这个对象是关联的,所以只有new了汽车这个对象才能执行汽车.发动
分享到:
评论

相关推荐

    Java解决No enclosing instance of type PrintListFromTailToHead is accessible问题的两种方案

    主要介绍了Java解决No enclosing instance of type PrintListFromTailToHead is accessible问题的两种方案的相关资料,需要的朋友可以参考下

    Eclipse快捷键大全(

    编辑 Select Enclosing Element Alt+Shift+向上键 Editing in Structured Text Editors 编辑 选择外层元素 Alt+Shift+向上键 编辑 Java 源代码 编辑 Restore Last Selection Alt+Shift+向下键 Editing in Structured...

    java-嵌套类(inner class)-来自oracle官网

    2.1.static nested class访问enclosing class(outer class)的成员 2.2.enclosing class(outer class)访问static nested class的成员 3.Non-static nested classes(Inner classes) 3.1.Non-Static Inner ...

    Borland Delphi 2005 Architect Update 3

    F2084 Internal Error SCR765.00 of 5 Closed11193 Inlined function affects working of the enclosing for loop0.00 of 5 Closed11184 [Fatal Error] F2084 Internal Error: ILLK26340.00 of 5 Closed11069 ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    Length Arrays and alloca() Friends Exceptions Run-Time Type Information (RTTI) Casting Streams Preincrement and Predecrement Use of const Integer Types 64-bit Portability Preprocessor Macros 0 and ...

    2009 达内Unix学习笔记

    集合了 所有的 Unix命令大全 ...telnet 192.168.0.23 自己帐号 sd08077-you0 ftp工具 192.168.0.202 tools-toolss ... 各个 shell 可互相切换 ksh:$ sh:$ csh:guangzhou% bash:bash-3.00$ ... 命令和参数之间必需用空格隔...

    Android Studio无法执行Java类的main方法问题及解决方法

    Android Studio升级到哦最新版3.6.1后,新建了个项目,发现无法执行Java类的main方法。试了网上的各种方法,比如切换gradle离线模式、gradle.properties中添加android.enableAapt2=false等,我还尝试了重新情况...

    max200技术手册

    数控等离子切割技术资料The user is responsible for installing and using the plasma equipment according to the manufacturer’s instructions. ...point where they are no longer troublesome.

    eclipse java注释模板

    * 创建一个新的实例 ${enclosing_type}. * * ${tags} */ </template> autoinsert="true" context="settercomment_context" deleted="false" description="Comment for setter method" enabled=...

    在线图片编辑 图片可拖动 裁剪区固定中间

    在线图片编辑 图片可拖动 裁剪区固定中间 有预览区 项目中应用

    Mask 98 for PRwin98

    is just a sample of the Windows 95/98 type enhancements Calmira provides to the Windows 3.1 user interface... Taskbar with versatile Start Menu, nested to any level Wastepaper bin to store deleted ...

    embedded system design

    into enclosing products such as cars, telecommunication or fabrication equipment. Such systems come with a large number of common characteristics, including real-time constraints, and dependability as...

    java开发中嵌套类的详解及实例

    主要介绍了 java开发中嵌套类的详解及实例的相关资料,一般把定义内部类的外围类成为包装类(enclosing class)或者外部类,需要的朋友可以参考下

    Eclipse新建项目不可选择Java Project问题解决方案

    主要介绍了Eclipse新建项目不可选择Java Project问题解决方案,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

    VB.NET Developer's Guide(4574).pdf

    enclosing parameters of function calls within parentheses regardless of whether we are returning a value or whether we are using the Call statement. It makes the code much more readable and is a new ...

    enclosing.zip_区域覆盖_圆与蜂窝_基站选择_小圆覆盖大圆_蜂窝最大覆盖

    本程序主要用于求解小圆覆盖大圆问题,本文求解过程中优先选择蜂窝状正六边形网格法求解。若正六边形网格不能恰好完整覆盖目标,此时,需要先采用圆周覆盖法将大圆圆周完整覆盖,再对大圆中心区域填补的方法,填补时...

    eclipse Code Templates

    * @version ${enclosing_type}${tags} * @since JDK 1.6 */ /** * * @Description TODO ADD Description. * ClassName:BaseService * * @Author 刘兆明 * @CreateDate 2015年7月20日 下午3:...

    外文翻译1

    thus an intractable preprocessing of enclosing blob gaps is necessary. Loy and B

    Fractions to Decimals

    If the decimal representation has a repeating sequence of digits, indicate the sequence by enclosing it in brackets. For example, 1/3 = .33333333...is denoted as 0.(3), and 41/333 = 0.123123123...is ...

    The accurate localization of fluorescent nanoparticle Au–Ft in nu/nu mice kidney

    Au–Ft, as a green synthesized nanoparticle, is composed of a ferritin nanocage enclosing a pair of Au nanoclusters inside. Our previous study has demonstrated that Au–Ft can be an excellent ...

Global site tag (gtag.js) - Google Analytics