Java: Comparing data types int and boolean


Here is the line to which i'm referring.
" Equality operators do not require that operands share the same ordering. For example, you can test equality across boolean, char, or int data types. "
Here is the link.


error:incomparable types:int and boolean


Hi boolean value are true or false


Right you are, boolean is not a numeric type.


thanks for the response,
but see when we use the code

char myChar = 'A';
int myInt = -2;
System.out.println(myChar == myInt);

the output is false

shouldn't this also give error


char and int are both numeric, so that's fine!

This explains what's going on:
Reading just the bold paragraph probably says enough


alphanumeric, aren't they? Containing letters and/or numbers?


It's an unsigned short (16 bits, 0 to 65535)