Java – is there any special reason for eclipse generated equals to use the values of 1231 and 1237 as Boolean values?

The title basically explains everything I tried Google search, but returned a lot of false positives I think I just want to know whether there are some reasons behind these two specific figures, or whether they can easily have many other figures?

Edit: and since the source of the numbers has been answered, any reason for the writer of the Boolean hashcode method to use these numbers (except that they are prime numbers)? Can any other prime number have an effect?

Solution

Hash functions tend to be collections Using prime numbers can reduce the number of collisions (considering the factors of prime numbers) 1231 and 1237 are prime numbers

/E1 after doing some research, I met this:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>