0

According to the output, java boolean false equals to 10011010101 and true equals to 4CF, 10011001111. I don't understand why java uses these value for boolean. And what exactly boolean is stored?

hakunami
  • 2,351
  • 4
  • 31
  • 50

1 Answers1

8

Documentation for the %h format specifier:

If the argument arg is null, then the result is "null". Otherwise, the result is obtained by invoking Integer.toHexString(arg.hashCode()).

I think this speaks for itself. false is boxed into Boolean.FALSE, and that object happens to have a hash code.

Marko Topolnik
  • 195,646
  • 29
  • 319
  • 436
  • 2
    And the `hashCode` for `true` is `1231`; `false` is `1237`. See http://stackoverflow.com/questions/3912303/boolean-hashcode – dejvuth Jul 30 '15 at 12:33