No enclosing instance of type Demo is accessible. Must qualify the allocation with an enclosing instance of type Demo (e.g. x.new A() where x is an instance of Demo).
No enclosing instance of type Demo is accessible. Must qualify the allocation with an enclosing instance of type Demo (e.g. x.new A() where
x is an instance of Demo).
在练习一Demo时,遇到上面的编译时错误

原因:main是Test类的static方法,按照常理它只能访问Test类中static资源,而class A是非static所以报错了。
解决方法一:给class F添加static属性。

解决方法二: 没有必要把F放在Demo中做内部类,将它移到Demo外部地方定义。

No enclosing instance of type Demo is accessible. Must qualify the allocation with an enclosing instance of type Demo (e.g. x.new A() where x is an instance of Demo).的更多相关文章
- No enclosing instance of type test is accessible. Must qualify the allocation with an enclosing inst
今日遇到一个报错如下: No enclosing instance of type test is accessible. Must qualify the allocation with an en ...
- 【转】Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
最近在看Java,在编译写书上一个例子时,由于书上的代码只有一部分,于是就自己补了一个内部类.结果编译时出现:No enclosing instance of type E is accessible ...
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing ...
- No enclosing instance of type test8 is accessible. Must qualify the allocation with an enclosing instance of type test8 (e.g. x.new A() where x is an
在编译一个例子时,结果编译时出现: No enclosing instance of type test8 is accessible. Must qualify the allocation wit ...
- No enclosing instance of type Outer is accessible. Must qualify the allocation with an enclosing instance of type Outer (e.g. x.new A() where x is an instance of Outer)
之前看内部类的时候没发现这个问题,今天写代码的时候遇到,写个最简单的例子: 下面这一段代码 红色的部分就是编译报错: No enclosing instance of type Outer is ac ...
- No enclosing instance of type Test is accessible. Must qualify the allocation with an enclosing instance of type Test (e.g. x.new A() where x is an instance of Test).
Java编写代码过程中遇到了一个问题,main方法中创建内部类的实例时,编译阶段出现错误,查看错误描述: No enclosing instance of type Test is accessibl ...
- 【eclipse】No enclosing instance of type A is accessible. Must qualify the allocation with an enclosing instance of type A
用 eclipse 写 Java 代码时出现了这个问题,详细如下: No enclosing instance of type TestParsingLinkedList is accessible. ...
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
在Java中,类中的静态方法不能直接调用动态方法.只有将某个内部类修饰为静态类,然后才能够在静态类中调用该类的成员变量与成员方法.所以在不做其他变动的情况下,最简单的解决办法是将public clas ...
- Java中报错No enclosing instance of type caiquan is accessible. Must qualify the allocation with an enclosing instance of type caiquan (e.g. x.new A() where x is an instance of caiquan).
package test;import java.util.Scanner;import java.util.Random;public class caiquan { public static v ...
随机推荐
- 开发Android逆向工具
韩梦飞沙 yue31313 韩亚飞 han_meng_fei_sha 313134555@qq.com 源代码及演示程序,请点击这里下载 下载地址: [北方网通] [电信网通] [下载说明] ...
- 【期望DP+高斯消元】BZOJ3270-博物馆
[题目大意] 有m条走廊连接的n间房间,并且满足可以从任何一间房间到任何一间别的房间.两个男孩现在分别处在a,b两个房间,每一分钟有Pi 的概率在这分钟内不去其他地方(即呆在房间不动),有1-Pi 的 ...
- textField代理方法
//textField代理方法// 返回no 不能输入文字- (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange ...
- winform WebBrowser如何修改使用默认的IE浏览器版本
在搜了一些相关资料原来WebBrowser使用的是IE的兼容模式进行浏览(IE7模式). 建议:先添加注册表中,然后使用注册表编辑器导出功能,产生reg注册文件:方便日后使用. Winform We ...
- gridview展开嵌套显示
最近实在是太忙了,好几个月没有更新博客了,近来项目需要用到GRIDVIEW嵌套的,在这里跟大家分享一下,大家如有更好的解决方案,请不吝贴出.在ASP.NET中,GridView嵌套可以显示当前选定的父 ...
- 用Hexo搭建属于自己的iOS技术博客,搬家了
搬家了,本来还打算在博客园混一段时间的,可是当我看到Hexo的时候,已经难以抵挡它的诱惑,简单不简约的界面让我花了整整一天的时间,买域名的过程中发生一点小问题导致DNS解析错误了,但还是成功了.欢迎朋 ...
- easyui combobox设置只读属性
$("#id").combobox('readonly',true); //只读 $("#id").combobox('readonly',false); // ...
- 【LaTeX】E喵的LaTeX新手入门教程(4)图表
这里说的不是用LaTeX画图,而是插入已经画好的图片..想看画图可以把滚动条拉到底.前情回顾[LaTeX]E喵的LaTeX新手入门教程(1)准备篇 [LaTeX]E喵的LaTeX新手入门教程(2)基础 ...
- 二.Consumer、Producer简单例子
1.先导入jar包,我使用的是maven <dependency> <groupId>com.alibaba.rocketmq</groupId> <arti ...
- ylbtech-LanguageSamples-UserConversions(用户定义的转换)
ylbtech-Microsoft-CSharpSamples:ylbtech-LanguageSamples-UserConversions(用户定义的转换) 1.A,示例(Sample) 返回顶部 ...