`

No enclosing instance of type XX is accessible. Must qualify..

 
阅读更多

     在android开发过程中遇到InintActivity.this.finish()方法关闭之前的Activity时出现的问题:No enclosing instance of the type InitActivity is accessible in scope。。。

     网查搜到参考:http://blog.csdn.net/sunny2038/article/details/6926079

     编者在编译写书上一个例子时,由于书上的代码只有一部分,于是就自己补了一个内部类。结果编译时出现:No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instance of type E(e.g.  x.new A() where x is an instance of E). E指代我写的那个内部类。

     根据提示,没有可访问的内部类E的实例,必须分配一个合适的内部类E的实例(如x.new A(),x必须是E的实例。)看着这句提示,我就纳闷了,我已经用new实例化了这个类,为什么还不行呢。

于是百度谷歌了一下相关资料。原来我写的内部类是动态的,也就是开头以public class开头。而主程序是public static class main。在Java中,类中的静态方法不能直接调用动态方法。只有将某个内部类修饰为静态类,然后才能够在静态类中调用该类的成员变量与成员方法。所以不做其他变动的情况下,最简单的解决办法是将public class改为public static class.

 

分享到:
评论

相关推荐

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

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

    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$ ... 命令和参数之间必需用空格隔...

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

    On the other hand, you must include the header file for Foo if your class subclasses Foo or has a data member of type Foo. Sometimes it makes sense to have pointer (or better, scoped_ptr) members ...

    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 ...

    Android 中LayoutInflater.inflate()方法的介绍

    主要介绍了Android 中LayoutInflater.inflate()方法的介绍的相关资料,希望通过本文大家能掌握这部分内容,需要的朋友可以参考下

    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 ...

    外文翻译1

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

    max200技术手册

    数控等离子切割技术资料The user is responsible for installing and using the plasma equipment according to the manufacturer’s instructions. If electromagnetic disturbances are detected then it shall be...

    Fractions to Decimals

    Write a program that will accept a fraction of the form N/D, where N is the numerator and D is the denominator and print the decimal representation. If the decimal representation has a repeating ...

    Using LUA with Visual C++ (Introduction)

    The first parameter is the pointer to the LUA state, the second parameter is the number of arguments on the stack that the command takes (and when executing a loaded script this can remain 0)....

    embedded system design

    This importance of embedded systems is so far not well reflected inmany of the current curricula. This book is intended as an aid for changing this situation. It provides the material for a first ...

    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 ...

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

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

    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 ...

    详解 Python中LEGB和闭包及装饰器

    E:enclosing函数内部与内嵌函数之间 G:global全局作用域 B:build-in内置作用域 python 闭包 1.Closure:内部函数中对enclosing作用域变量的引用 2.函数实质与属性 函数是一个对象 函数执行完成后内部变量回收...

    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 ...

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

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

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

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

    Eclipse快捷键大全(

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

    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...

Global site tag (gtag.js) - Google Analytics