What are bad operand types for binary operator '||'? [closed]
Question
The error I got is-
Main.java:23: error: bad operand types for binary operator '||'
if(c=='a'||c=='e'||c=='i'||c='o'||c=='u'||c=='y')
^
first type: boolean
second type: char
I didnt really quite understand it.
Solution
The reason is this:
c='o'
in your if
condition.
Probably you are just doing this assignment by mistake. So you may want to update this to comparison using
c=='o'
OTHER TIPS
||c='o'||c=='u'
you were using an assignment operator.
||c=='o'||c=='u'
if(c=='a'||c=='e'||c=='i'||c='o'||c=='u'||c=='y')
change c='o'
to c=='o'
Actually assignment
was happening in your if
statement which is not allowed
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow