下面是代码,这里抛出的错误是错误: java.lang.Integer无法强制转换为java.lang.Double
package swing3;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class rob {
public static void main(String[] args) {
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine engine = mgr.getEngineByName("JavaScript");
我在这里得到一个错误:
String a = "3+5";
try {
double b = (Double)engine.eval(a);
System.out.println(b);
} catch (ScriptException e) {
e.printStackTrace();
}
}
}