How to convert string to operator in java

后端 未结 9 1672
情歌与酒
情歌与酒 2021-01-16 03:12

I want to convert some String to an operator like this:

int value = 1;
int valueToCompare = 3;
String operation = \"<\";

if (value operation         


        
9条回答
  •  感情败类
    2021-01-16 04:12

    The simplest way would be a chain of if-else statements checking what the the operator is and then performing the mathematical expression.

提交回复
热议问题