Code如下: 1importjava.io.FileNotFoundException;2importjava.io.IOException;3importjava.io.InputStream;4importjava.util.Properties;56publicclassGetProperties {//不用static7publicString getCotent(){//不用static8String
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 4 5 6 7 8 9 10 可是还是错的。。。 翻了一下java书才知...
解决办法是 在赋值前添加代码:Segmentimprove gp=new Segmentimprove();//类的实例化 其中Segmentimprove是java类的类名,也就是首先要把类实例化,这样method返回的string在内存中就有了存储位置。 具体请参考:http://blog.csdn.net/aeolus1019/article/details/7974430 ...
The "Cannot make a static reference to the non-static method" error occurs when you try to call a non-static method from a static context. In Java, non-static methods (also known as instance methods) belong to an instance of a class and can be called only on an instance of the ...
代码太那个了吧那个错误的意思是静态方法不能引用一个非静态的成员变量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 method get() from the type Test1 好吧,我决定改成这样 public class Test1 { public String get() { return "123"; } public static void main(String[] args) { static String string =get(); } } 可是还是错的。。。 翻了一下java书才知道...
百度试题 结果1 题目java报错:Cannot make a static reference to the non-static method getTitle() from the type Book 相关知识点: 试题来源: 解析 展开全部 右边输出的Book都小写就没问题了。大写Book是类,小写book是你建立的对象。 反馈 收藏
“Cannotmakeastaticreferencetothenon-staticmet。。。报错原⽂:Cannot make a static reference to the non-static method maxArea(Shape[]) from the type ShapeTestb 报错原因:在⼀个类中写了⼀个public void maxArea ()⽅法和⼀个main()⽅法,在main()⽅法中直接调⽤maxArea()⽅法就...
Cannot make a static reference to the non-static method的解决方法,报错原因:在一个类中写了一个publicStringgetContent()方法和一个main()方法,getContent()方法中包含了getClass()方法,在main()方法中直接调用了getContent()就出现如题的错误。这样一样解决方法:
- -!User是一个类名,用类名只能调静态方法,你这个getUserName是非静态方法,所以要在对象上面调用,先要获取一个User类的对象 User user = new ("用户",false);(或者其他方式获取对象),然后再调用user.getUserName();或者你是有个全局变量user,把User中的U改成u就行了~con...