Java String convertion into Integer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Java String convertion into Integer

I have a string like str= "25+25" .What I want is convert into Integer this string so that real operation will happen to give the final result of 50

14th Dec 2017, 1:51 PM
MONSIEUR GNETO
MONSIEUR GNETO - avatar
1 Answer
0
https://stackoverflow.com/questions/2605032/is-there-an-eval-function-in-java ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("js"); Object result = engine.eval("25+25"); Maybe this will help? I think this runs JS code inside a Java program
14th Dec 2017, 2:58 PM
Augustinas Lukauskas
Augustinas Lukauskas - avatar