I am working on a program to make a program in which the user plays craps. I know there are more problems, as this is a work in progress, but first I need to complete public static boolean play before I can move forward. When I try to compile, I get an error message that says "bad operand types forbinary '||' first type: int; second type: boolean" while the compiler highlights "|| result ==11" what does this error message mean and can someone point me in the right direction of how to fix it? Or is it a simple fix that I am missing? Any help is GREATLY appreciated. I have banging my head on the wall over this one for a couple hours now.
Once again, I cannot give enough thanks for any help.
Thanks Anayonkar, but aren't both of my operands "result"? I am new to Java so I am not entirely sure. If my operands are "result" why does the first one on that same line work just fine and the error message only appears on the second instance of result? Also, according to my instructions, result needs to be an int. So confused...
Stanley Mungai wrote: . . . Both sides need to be either....Got it now?
No, both sides must be “boolean”. It will work with a small b or a capital B because of un-boxing (since Java5 in 2004). The details are in the Java Language Specification, but they are slightly different for the | operator, which can take ints as operands.
Anyway, as has already been mentioned, the real error was confusing == and =.
posted 6 years ago
Thanks, it was just a simple oversight but the compiler message just confused me.