fronthem
fronthem

Reputation: 4139

How can I convert strings to operators in Java?

I have "+" and I want to use it as "if(1 + 2 == 3)"

Upvotes: 0

Views: 3966

Answers (1)

Jeffrey
Jeffrey

Reputation: 44808

If you want to evaluate "1+2" as a mathematical equation: Evaluating a math expression given in string form

If you want to evaluate if(1+2==3) as an if statement, java should do that for you.

Upvotes: 2

Related Questions