The compiler wants you to provide compatible types. Some languages let internal knowledge leak through, like false is zero and true is one, or maybe anything not zero.
Java chose not to do that. They probably decided the kind of shortcut that lets you compare different types is too much opportunity for error.