Why does Java use 31 in hashCode?

The value 31 was chosen because it is an odd prime . If it were even and the multiplication overflowed, information would be lost, as multiplication by 2 is equivalent to shifting. The advantage of using a prime is less clear, but it is traditional.

Sizin İçin Seçtik  What is the biggest app on iPhone?

Leave a Reply

Your email address will not be published. Required fields are marked *