今天在写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.

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

相关文章:

  • 2021-11-17
  • 2022-12-23
  • 2022-01-01
  • 2021-08-05
  • 2022-02-03
  • 2022-12-23
  • 2021-06-30
猜你喜欢
  • 2021-05-24
  • 2021-07-24
  • 2021-06-02
  • 2021-08-16
  • 2022-12-23
  • 2021-08-15
  • 2022-12-23
相关资源
相似解决方案