报错cannot be referenced from a static context的解决方法

 

直接上代码图,后认识到main方法是一个static方法,class Clerk是一个非静态的内部类,只能被该类的非静态方法访问。否则会报错。

解决方法:

1.在class前加上static

2.将该类移出来。

猜你喜欢

转载自www.cnblogs.com/celtics-huha/p/12076203.html
今日推荐