Java吧字符串转成可计算的公式

package com.xf.practice;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.util.ArrayList;

public class TestArrayList {
    public static void main(String[] args) throws ScriptException {
         ScriptEngine jse = new ScriptEngineManager().getEngineByName("JavaScript");
        Object aa = jse.eval("1/1000");
        System.out.println(aa);
       /* ArrayList arrayList = new ArrayList(100);
        arrayList.add("1");*/
    }
}

得出结果:0.001

你可能感兴趣的:(Java)