一、原因

出现上面错误的原因是,类UserInfo在ComparatorTest2中

public class ComparatorTest2 {public static void main(String[] args) {UserInfo u1 = new UserInfo();}class UserInfo{private String name;private int age;public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}}}

二、解决方案

将类UserInfo移出去就好了

解决 enclosing instance of type XXX(你的类)(e.g. x.new A() wher x is an instance of XXX(你的类)).相关推荐

  1. java解决 No enclosing instance of type XXX is accessible的问题

    有些时候我们要把Activity的一些实现类移到java类里来实现,比如把写以下两个类: 在LifeCircle这个类中: public class LifeCircle {public class ...

  2. Java变异出现错误:No enclosing instance of type XXX is accessible

    摘要:写java代码时遇到下面的编译错误. 本文分享自华为云社区<Java中出现No enclosing instance of type XXX is accessible问题>,作者: ...

  3. 解决No enclosing instance of type * is accessible

    写一个内部类,并在构造函数中初始化时,遇到报错,搜索问题后发现,有网友出现过类似的问题,下面这个是说的浅显明白的,并确实解决了问题.于是,以下内容照搬过来,不再多费键盘了. public class ...

  4. No enclosing instance of type xxx is accessible

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

  5. Java中出现No enclosing instance of type Demo01 is accessible解决方法参考

    出现类似以下错误 No enclosing instance of type Demo01 is accessible. Must qualify the allocation with an enc ...

  6. No enclosing instance of type 错误的解决方法

    今天做练习的时候碰到的小问题: No enclosing instance of type Test02 is accessible. Must qualify the allocation with ...

  7. enclosing type java_Java中出现No enclosing instance of type XXX is accessible问题

    Java编写代码过程中遇到了一个问题,main方法中创建内部类的实例时,编译阶段出现错误,查看错误描述: Multiple markers at this line - The value of th ...

  8. 异常: No enclosing instance of type xx is accessible. Must qualify (Java 内部类)

    异常 前言. 开发时候遇到内部类的问题. 异常 No enclosing instance of type SparkProgrammingGuide is accessible. Must qual ...

  9. No enclosing instance of type JDStudent is acAcessible. Must qualify the allocation with an enclosin

    No enclosing instance of type JDStudent is acAcessible. Must qualify the allocation with an enclosin ...

最新文章

  1. centos7.0 lamp mysql_CentOS7 yum安装LNMP以及LAMP
  2. Wince 添加中文字库
  3. 区块链学习之区块链思想的诞生(一)
  4. 善用Object.defineProperty巧妙找到修改某个变量的准确代码位置
  5. 今天可免费用VR观看第51届超级碗大赛直播
  6. UVA12190 Electric Bill【二分搜索】
  7. 计算机病毒能破坏u盘文件,[计算机病毒]快捷方式病毒(U盘文件变为快捷方式)...
  8. idea导出快捷键配置
  9. Docker 下载安装使用(简单教程)
  10. 基于微信小程序的扫码签到系统源码
  11. Kotlin 密封类
  12. web漏扫问题处理1
  13. python命令行参数是什么
  14. php 获取微博cookie,c#获取新浪微博登录cookie
  15. 【算法】Sunday算法(模式匹配)
  16. 为什么8G运行内存的电脑,开几个WORD文档,运行内存就被占满了,WPS很占用内存吗
  17. VS Code保存文件时自动删除行尾空格
  18. 超零协议(SERO)轻松入门——基于CENTOS7
  19. 企业如何选择合适的精益生产方案?
  20. Depix:还原马赛克工具的试用及总结

热门文章

  1. 网易云音乐开发--前后端交互
  2. 免费手机上网的方法,比GPRS网速快很多(好东西与大家分亨)
  3. brew下载的mysql卸载_【已解决】Mac中如何彻底卸载之前通过dmg安装的mysql
  4. c语言123输出112233,c语言练习 - 噫_的个人空间 - OSCHINA - 中文开源技术交流社区...
  5. CSS——CSS样式的几种写法
  6. Solr 配置文件之core.properties、solr.xml和Config Sets
  7. [hive]数仓分层|用户纬度拉链表|维度建模
  8. 构建关系抽取的动词源
  9. python调用canape_利用CANape进行基于CCP的汽车控制器的匹配标定的设计
  10. 数学一年级应用题_小学一年级数学下册应用题练习题归纳