I'm java beginner and I'm learning about switch statement. I understand how switch statement works but when I try to convert from switch to if/else I got wrong answer. And I couldn't get the problem?
This is the switch statement
switch (y)
{
case '+':
case '-':
checkPrecedence(y, 1);
break;
case '*':
case '/':
checkPrecedence(y, 2);
break;
case '(':
opStack.push(y);
break;
case ')':
checkBrackets();
break;
default:
output = output + y;
break;
my if/else statment
if (y == '+' || y == '_') {
checkPrecedence(y, 1);
}
else if (y == '*' || y == '/') {
checkPrecedence(y, 2);
}
else if (y == '(') {
opStack.push(y);
}
else if (y == ')') {
checkBrackets();
}
output = output + y;