报错cannot be referenced from a static context的解决方法
Posted celtics-huha
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了报错cannot be referenced from a static context的解决方法相关的知识,希望对你有一定的参考价值。
直接上代码图,后认识到main方法是一个static方法,class Clerk是一个非静态的内部类,只能被该类的非静态方法访问。否则会报错。
解决方法:
1.在class前加上static
2.将该类移出来。
以上是关于报错cannot be referenced from a static context的解决方法的主要内容,如果未能解决你的问题,请参考以下文章
在eclipse中新建java问题报错:The type XXX cannot be resolved. It is indirectly referenced from required .clas
杂-The type java.lang.Object cannot be resolved It is indirectly referenced ...
The type java.lang.reflect.AnnotatedElement cannot be resolved. It is indirectly referenced from req
The type XXX cannot be resolved. It is indirectly referenced from required .class files错误.
The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class
The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class