今天写demo的时候,遇到一个问题,关于内部类的,这里写一下

错误信息:No enclosing instance of type TextRunnable is accessible. Must qualify the allocation with an enclosing instance of type TextRunnable (e.g. x.new A() where x is an instance of TextRunnable).

解决的方法,很容易

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

No enclosing instance of type TextRunnable is accessible. Must qualify the allocation with an enclo相关推荐

  1. [Java]Error:No enclosing instance of type E is accessible. Must qualify the allocation with an enclo

    在自己试着写一个链表的例子时,由于参考的代码只有一部分,于是就自己补了一个内部类.结果编译时出现:No enclosing instance of type E is accessible. Must ...

  2. No enclosing instance of type SmsUtils is accessible. Must qualify the allocation with an enclosing

    No enclosing instance of type SmsUtils is accessible. Must qualify the allocation with an enclosing ...

  3. Java出现No enclosing instance of type Test is accessible. Must qualify the allocation with an enclosin

    最近研究LDA源代码时,里面涉及到Comparable方法的使用.以前用过这个排序方法,现在想回顾一下.以下是程序,感觉没问题啊,结果报错了: Exception in thread "ma ...

  4. No enclosing instance of type FormDetailBean is accessible. Must qualify the allocation with an encl

    最近在看Java,在编译写书上一个例子时,由于书上的代码只有一部分,于是就自己补了一个内部类.结果编译时出现:No enclosing instance of type E is accessible ...

  5. No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instanc

    java : No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing ...

  6. 语法错误:No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing

    错误 问题 No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing 没 ...

  7. No enclosing instance of type X is accessible. Must qualify the allocation with an enclosing instanc

    No enclosing instance of type X is accessible. Must qualify the allocation with an enclosing instanc ...

  8. No enclosing instance of type Main is accessible. Must qualify the allocation with an enclosing i...

    最近在刷AC,在编译时出现: No enclosing instance of type Main is accessible. Must qualify the allocation with an ...

  9. No enclosing instance of type testTry is accessible. Must qualify the allocation...之解决方法

    报错原因: 因为在做异常处理测试时,我写的内部类是动态的,即public class开头无static关键字修饰,而测试主程序是静态的main方法:在Java中,类中的静态方法不能直接调用动态方法.只 ...

最新文章

  1. 转:Oracle SQL 内置函数大全 (一)
  2. linux软中断分析,linux操作系统下的软中断问题分析_linux教程
  3. 事半功倍:推荐系统Pre-train预训练方法
  4. javascript之嵌套函数
  5. 在VMWare上安装CentOS8
  6. 远程LInux和秘钥认证
  7. java date和localdate_Java8 Date与LocalDate互转
  8. python第八十八天----dom js
  9. pytorch---模型保存于加载(4)在一个文件中保存多个模型
  10. 我们总结了每个技术团队都会遇到的 4 个难题 1
  11. 软件创始人必须要知道的事情
  12. 哈夫曼编码问题(贪心)
  13. Html5中,input标签所有Type类型介绍
  14. 等待任务执行完成时,界面上转圈圈,不让用户操作软件
  15. vue实现组件隔代通信(在孙组件调用爷组件的方法)
  16. 开源优测-积微速成计划历次任务及总结
  17. mybaits-plus 代码生成器
  18. 魔兽世界不同服务器集合石显示的内容,魔兽怀旧服:详解TBC集合石机制,各副本要求不同,难怪无法使用...
  19. XJTU_ 西安交通大学2020大学计算机作业-第八周
  20. 状态转移矩阵 matlab,用不同状态序列长度估计MATLAB中的马尔可夫链转移矩阵

热门文章

  1. 同音不同字的商标名称,是否会被核准注册 ?
  2. 粘贴板管理 android,安卓剪贴板管理(Clipper Plus)
  3. crontab python不生效_crontab 中 python 脚本执行失败的解决方法
  4. 无刷直流电机的PWM调制方式介绍
  5. C++ Primer勘误
  6. 评论:26岁成都唐爽发现成果惊动奥巴马--意外发现新材料极可能成下一代电脑芯片...
  7. 电脑音频服务器未修复咋办,音频服务未运行怎么办?win7和win10电脑没声音了恢复方法...
  8. Echarts折线图曲线图和三维图
  9. MATLAB | 如何从热图中提取数据
  10. 在服务器端运行JavaScript文件(一)