第一种类型布尔第二种类型char java错误

时间:2017-01-25 03:54:10

标签: java compiler-errors

if( (mychar == '+' || mychar == '-') && (stack.peek() ==  '+' || stack.peek() = '-') )

我收到以下错误:

bad operand types for binary operator '||'
first type:  boolean
second type: Character

我已多次检查过,但我无法弄明白。

1 个答案:

答案 0 :(得分:1)

你忘了在结尾添加双倍==。

应该是stack.peek() == '-',而不是stack.peek() = '-'