含运算符的字符串直接运算

js:  结果等于 eval(字符串);

java:   ScriptEngineManager factory = new ScriptEngineManager();
          ScriptEngine engine = factory.getEngineByName("JavaScript");

    结果等于 engine.eval(字符串);

    简写:结果等于 (new ScriptEngineManager()).getEngineByName("JavaScript").eval(字符串);

转载于:https://www.cnblogs.com/jetereting/p/5004807.html

你可能感兴趣的:(含运算符的字符串直接运算)