我使用下面的代码制作我的scriptEngine。它工作正常,直到我尝试进行包含双打的计算。下面的代码应该返回30但是返回5.我做错了什么或者scriptEngine不能做双打?
String calculation = "20*1.5";
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine engine = mgr.getEngineByName("JavaScript");
String s = engine.eval(calculation).toString();
System.out.println("Test: " + s);
double answer = Double.parseDouble(s);
System.out.println("Answer: \t" + answer);