首页 > 数据库技术 > 详细

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

时间:2017-02-19 21:07:05      阅读:301      评论:0      收藏:0      [点我收藏+]

今天在写SAX解析,用到了继承,我把父类写成了内部类,出现了No enclosing instance of type saxDom is accessible to invoke the super constructor. Must define a constructor and explicitly qualify its super constructor invocation with an instance of saxDom (e.g. x.super() where x is an instance of saxDom).错误

 

网上查找了错误原因如下:

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

在这里记下这个问题,也方面遇到同样问题的朋友查阅。

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

原文:http://www.cnblogs.com/xujingyang/p/6416789.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!