Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Convert Strings To Mathematical Expressions In java

import javax.script.ScriptEngineManager;
import javax.script.ScriptEngine;
import javax.script.ScriptException;

public class Test {
  public static void main(String[] args) throws ScriptException {
    ScriptEngineManager mgr = new ScriptEngineManager();
    ScriptEngine engine = mgr.getEngineByName("JavaScript");
    String foo = "40+2";
    System.out.println(engine.eval(foo));
    } 
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Convert #Strings #To #Mathematical #Expressions #In #java
ADD COMMENT
Topic
Name
9+1 =