报错原因:

因为在做异常处理测试时,我写的内部类是动态的,即public class开头无static关键字修饰,而测试主程序是静态的main方法;在Java中,类中的静态方法不能直接调用动态方法。只有将某个内部类修饰为静态类,才可以在静态类中调用带类的成员变量和成员方法:

解决方法:

将动态内部类改为静态(public static class)即可:

No enclosing instance of type testTry is accessible. Must qualify the allocation...之解决方法相关推荐

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

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

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

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

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

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

  5. 语法错误: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 没 ...

  6. No enclosing instance of type TextRunnable is accessible. Must qualify the allocation with an enclo

    今天写demo的时候,遇到一个问题,关于内部类的,这里写一下 错误信息:No enclosing instance of type TextRunnable is accessible. Must q ...

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

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

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

最新文章

  1. 浅谈Python flask框架浅析
  2. Linux下使用NTFS格式移动硬盘
  3. 机器学习算法-Adaboost
  4. Elementui动态换肤
  5. 实例1.1:通过HWND获得CWnd指针
  6. [转]基于SQL Server 2008 Service Broker构建企业级消息系统
  7. CSS3动画框架 Animate.css
  8. 手把手教你Tiny4412 Android5.0 定制 按下开发板上的按键通过广播发送到应用层
  9. 如何在windows上搭建DZ(Discuz!)论坛?
  10. 摄影系列:李涛ps视频教程笔记
  11. ios 越狱后 重启springboard 命令
  12. python实现——WORD转PDF(全自动化,支持doc、docx)
  13. 文本摘要(text summarization)任务:研究范式,重要模型,评估指标(持续更新ing...)
  14. 如果兔子拼命奔跑 乌龟怎么办
  15. 值得看三次的高干文_5本精彩的高干文推荐,本本是经典,值得刷三遍以上!...
  16. python 3 12306余票查询脚本
  17. php英文随机验证码,PHP随机字母数字验证码
  18. 使用jQuery用键盘去控制图片移动
  19. SSM框架自学笔记--------巨细!!!!!!!!
  20. 经济危机为什么也是创业良机?

热门文章

  1. #个人日记-电影《明日之战》观后感-20210913
  2. 亚信安全明日上市:市值将超百亿 募资12亿
  3. 5ecsgo启动失败2错误代码2_华纳确定正式启动明日边缘2电影项目
  4. 大厂机密!乔戈里在BAT大厂都用些什么?大揭秘
  5. 一个MMORPG游戏的常规技能系统
  6. 5G 学习笔记 - NSA - ENDC架构
  7. 类图,类与类之间的关系
  8. linux qt 背景图片,qt设置背景图片
  9. Python+tkinter库实现简单图书管理系统
  10. 计算机类大学生可以参加的5个比赛