Stringstring=get(); } } 1 2 3 4 5 6 7 8 9 10 显示 Cannot make a static reference to the non-static method get() from the type Test1 好吧,我决定改成这样 publicclassTest1{publicStringget(){return"123"; }publicstaticvoidmain(String[] args){staticStringstring=get(); } } 1 2 3...
/*** Will not compile*/publicclassStaticReferenceToNonStatic {publicstaticvoidmyMethod() {//Cannot make a static reference//to the non-static methodmyNonStaticMethod(); }publicvoidmyNonStaticMethod() { } }/*** you can make your method non-static*/publicclassMyClass {publicvoidmyMethod() {...
百度试题 结果1 题目java报错:Cannot make a static reference to the non-static method getTitle() from the type Book 相关知识点: 试题来源: 解析 展开全部 右边输出的Book都小写就没问题了。大写Book是类,小写book是你建立的对象。 反馈 收藏
/*** Will not compile*/publicclassStaticReferenceToNonStatic {publicstaticvoidmyMethod() {//Cannot make a static reference//to the non-static methodmyNonStaticMethod(); }publicvoidmyNonStaticMethod() { } }/*** you can make your method non-static*/publicclassMyClass {publicvoidmyMethod() {...
代码太那个了吧那个错误的意思是静态方法不能引用一个非静态的成员变量public class Takecare{static int a=90;static float b=10.98f;public static void p() {float c = a + b;System.out.println(c);}public static void main(String[] args) {Takecare.p();}}静态的东西不能引用到非...
Cannot make a static reference to the non-static field x:意思是无法再静态方法中引用一个非静态变量x 下面是对关键字Static的理解 1、关键字static(类方法,实例方法) ①:静态方法和静态变量是属于某一个类,而不属于类的对象。 ②:静态方法和静态变量的引用直接通过类名引用。
所以解决办法是将public class改为public static class. 9.错误:Cannot make a static reference to the non-static method 原因:在一个类中写了一个public String getContent()方法和一个main()方法, getContent()方法中包含了getClass()方法,在main()方法中直接调用了getContent()就出现如题的错误。
我的主要问题是我不断收到一条错误消息: Cannot make a static reference to the non-static field balance. 我已经尝试使方法静态化,但没有结果,并通过从标头中删除“静态”使主要方法非静态化,但随后我收到消息: java.lang.NoSuchMethodError: main Exception in thread "main" 有人有什么想法吗?任何帮助表示...
I make jar file of JavaParser and I want to run example How to extract the name of all classes in a normal String from java class? in https://tomassetti.me/getting-started-with-javaparser-analyzing-java-code-programmatically/ but I conflict with error Cannot make a static reference to the...
Exception in thread "main" java.lang.Error: Unresolved compilation problem: Cannot make a static reference to the non-static method getAge() from the type Sample 从静态方法中调用非静态方法就是声明调用非静态方法的类的实例。 阅读此关于非静态方法和静态方法之间区别的阐述。 20.“(array) <X> Not...