0

I have a equation in string format like "45+5*4-6" which I have to solve in Java.

Is there any way to solve equation which is in string format?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
johntom
  • 25
  • 6

1 Answers1

1

Check Beanshell

Something like this should work -

Interpreter ip = new Interpreter();
ip.eval("res = 45+5*4-6");
System.out.print(ip.get("res"));
Bhushan Bhangale
  • 10,921
  • 5
  • 43
  • 71