You can use the ScriptEngine
class and evaluate it as a Javascript string.
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("js");
Object result = engine.eval("4*5");
There may be a better way, but this one works.
More Related Contents:
- split US phone number in java? [closed]
- Meaning of some operator in java [closed]
- Q. If you compile and execute an application with the following code in its main() method: Why ” s” is created two objects [duplicate]
- Java Serializable Object to Byte Array
- How to enter quotes in a Java string?
- “Code too large” compilation error in Java
- Integer wrapper objects share the same instances only within the value 127? [duplicate]
- how to parse JSONArray in android
- How to deploy a war file in Tomcat 7
- java.lang.UnsatisfiedLinkError no *****.dll in java.library.path
- MouseMotionListener in Java Swing, using it with components inside components etc
- Dynamic variable names Java
- How can I resize an image using Java?
- Why does (360 / 24) / 60 = 0 … in Java
- How delete a collection or subcollection from Firestore?
- How to manually set an authenticated user in Spring Security / SpringMVC
- How to implement infinity in Java?
- what is the right way to get request’s ip [duplicate]
- How can a derived class invoke private method of base class?
- Memory barriers and coding style over a Java VM
- Hibernate use of PostgreSQL sequence does not affect sequence table
- Java check if two rectangles overlap at any point
- Encourage the JVM to GC rather than grow the heap?
- Is there anyway to exclude artifacts inherited from a parent POM?
- JFreeChart – Problem in creating moving chart
- Arrays.asList() of an array
- Is having a single threadpool better design than multiple threadpools
- why autoimport only java.lang package?
- Integration Test with Spring Boot and Spock
- The local variable might not have been initialized – Detect unchecked exception throw within a method