Search
 
SCRIPT & CODE EXAMPLE
 

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));
    } 
}
Comment

PREVIOUS NEXT
Code Example
Java :: android studio get id name from view 
Java :: remove duplicate from string 
Java :: recursion in java 
Java :: how to run java in eclipse 
Java :: convert list of dto to map java 
Java :: array to string java 
Java :: current time stamp android java 
Java :: how to convert arraylist to iterable in java 
Java :: BottomNavigationView only icon 
Java :: print double without decimal java 
Java :: java ignore catch 
Java :: get input in java 
Java :: $JAVA_HOME ENV 
Java :: java swing get frame size 
Java :: how to sort arraylist 
Java :: how to find the largest number in java 
Java :: how to create xml file in java 
Java :: convert class to java 
Java :: Syntax of how to create ArrayList in Java 
Java :: on item click listener for recyclerview adapter 
Java :: objectmapper in java 8 
Java :: Programme to calculate Combination 
Java :: write content to file java 
Java :: traversing treemap in java 
Java :: thread implements runnable 
Java :: initializing list in java 
Java :: java add a list to a list 
Java :: how to return arraylist as array in java 
Java :: default java keystore 
Java :: Task :run FAILED Error: Could not find or load main class Caused by: java.lang.ClassNotFoundException: 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =