Here is the code bellow is where is the error thrown here is the error: java.lang.Integer cannot be cast to 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");
Here i got an error:
String a = "3+5";
try {
double b = (Double)engine.eval(a);
System.out.println(b);
} catch (ScriptException e) {
e.printStackTrace();
}
}
}