Cannot make a static reference to the non-static method getRs(String) from the type bsh_tt求解?
packagecom.test.hdsa;importbsh.EvalError;importbsh.Interpreter;publicclassbsh_tt{publ...
package com.test.hdsa;
import bsh.EvalError;
import bsh.Interpreter;
public class bsh_tt {
public static void main(String[] args) {
System.out.print("Hello world");
String exp="9.0*3.0";
exp=getRs(exp);
System.out.print(exp);
}
public String getRs(String exp){
Interpreter bsh = new Interpreter();
Number result = null;
try {
result = (Number)bsh.eval(exp);
} catch (EvalError e) {
// TODO Auto-generated catch block
e.printStackTrace();
}//运行表达式的值eval();
return result.floatValue()+"";//为什么doubleValue 0.6*9就会报错
}
} 展开
import bsh.EvalError;
import bsh.Interpreter;
public class bsh_tt {
public static void main(String[] args) {
System.out.print("Hello world");
String exp="9.0*3.0";
exp=getRs(exp);
System.out.print(exp);
}
public String getRs(String exp){
Interpreter bsh = new Interpreter();
Number result = null;
try {
result = (Number)bsh.eval(exp);
} catch (EvalError e) {
// TODO Auto-generated catch block
e.printStackTrace();
}//运行表达式的值eval();
return result.floatValue()+"";//为什么doubleValue 0.6*9就会报错
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询