0
String num = "9+9";
double answer = Double.parseDouble(num);

I understand I could use something called ScriptEngineManager. I copied that code, and was given the following error:

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "javax.script.ScriptEngine.eval(String)" because "engine" is null
    at WritingClasses.Test.EvalMath(Test.java:25)
    at WritingClasses.Test.main(Test.java:11)
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
  • parse it yourself maybe, use regex to split numbers and variables do the calculation on your own – Siva Rahul Jun 04 '22 at 04:58
  • See also: [*How to use Nashorn in Java 15 and later?*](https://stackoverflow.com/q/65265629/642706) and [*Nashorn removal: GraalVM to the rescue!*](https://medium.com/graalvm/nashorn-removal-graalvm-to-the-rescue-d4da3605b6cb) – Basil Bourque Jun 04 '22 at 06:57

0 Answers0