在Java中使用ScriptEngine动态执行代码(解决带运算符的字符串的运算)
ScriptEngine js = new ScriptEngineManager().getEngineByName("JavaScript");
System.out.println("1+2的和 :"+js.eval("1+2"));
System.out.println("1-2的差 :"+js.eval("1-2"));
System.out.println("1*2的积 :"+js.eval("1*2"));
System.out.println("1/2的商 :"+js.eval("1/2"));
System.out.println("1%2的余:"+js.eval("1%2"));