String "1+1" to int 2

I need to evaluate a math expression in string format, so a given String “100+1” should return 101. In java this is known as eval: JavaScript eval() Method

Your going to need to parse it yourself. For just addition it’s trivial, for being able to handle any math expression it becomes more involved.

The link you provided is JavaScript, not to be confused with Java. Very different.