I have "+" and I want to use it as "if(1 + 2 == 3)"
Asked
Active
Viewed 3,924 times
0
-
Do you mean that you want to know how to write a program that parses a mathematical expression (like "1 + 2 == 3")? – siride Jul 16 '11 at 03:13
-
Java does not have eval, if that's what you mean. For that, use JavaScript / ECMAScript. – wberry Jul 16 '11 at 03:15
-
might want to try http://docs.codehaus.org/display/JANINO/Home – MeBigFatGuy Jul 16 '11 at 04:03
1 Answers
2
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.