Hi,
Does anyone know why Boolean true(1231) and false(1237) have these hashcodes ?
The main question is why 1231 for true and why now say 1
and 1237 for false and why not say 0 or 2.
Secondly are there any more static predefined values in JDK which have predefined hashCodes ?
Regards
Chetan
-
Hashcode 1231 and 1237 (1 messages)
- Posted by: Chetans
- Posted on: May 26 2003 05:12 EDT
Threaded Messages (1)
- Hashcode 1231 and 1237 by Gal Binyamini on May 26 2003 15:31 EDT
-
Hashcode 1231 and 1237[ Go to top ]
- Posted by: Gal Binyamini
- Posted on: May 26 2003 15:31 EDT
- in response to Chetans
Probably they were chosen because they are two prime numbers. Since they most probably will have no common divisors with the hashtable size (unless the prime itself divises the hashtable size), the chances of collision in common hashtable implementations would be minimized. That said, 0 and 1 should also work well in most implementations. Perhaps the JLS envisioned some other implementation I can't think of at the moment... or maybe they thought 0 and 1 would be common hash keys, and wanted to chose something else to reduce chances of collision.
Gal