How to evaluate a math expression given in string form?
Asked 07 September, 2021
Viewed 2.4K times
  • 55
Votes

I'm trying to write a Java routine to evaluate math expressions from String values like:

  1. "5+3"
  2. "10-40"
  3. "(1+10)*3"

I want to avoid a lot of if-then-else statements. How can I do this?

25 Answer