The hashCode() method of class Boolean is implemented like this:
public int hashCode() {
return value ? 1231 : 1237;
}
Why does it use 1231 and 1237? Why not something else?
The hashCode() method of class Boolean is implemented like this:
public int hashCode() {
return value ? 1231 : 1237;
}
Why does it use 1231 and 1237? Why not something else?
In addition to all that's said above it can also be a small easter egg from developers:
true: 1231 => 1 + 2 + 3 + 1 = 7
7 - is a lucky number in European traditions;
false: 1237 => 1 + 2 + 3 + 7 = 13
13 (aka Devil's dozen) - unlucky number.