import javax.script.*; public class Solution { public int solve (String s) throws Exception { return (Integer) new ScriptEngineManager().getEngineByName("js").eval(s); } } Java调用js引擎,利用js的eval函数,一行秒