我想在Android中实现以下代码。我该怎么做?
System.out.println("Enter a String");
Scanner sc = new Scanner(System.in);
String string = sc.next();
System.out.println(new ScriptEngineManager().getEngineByName("JavaScript").eval(string));//this is solving infix expression using javascript
答案 0 :(得分:0)
你试过施展吗?像这样,
double a = (double) engine.eval("25+36");
或者这个(toString());
System.out.println(new ScriptEngineManager().getEngineByName("JavaScript").eval(string).toString());