- 浏览: 1121 次
- 性别:
- 来自: 北京
最新评论
文章列表
Why does Java's hashCode() in String use 31 as a multiplier?
In Java, the hash code for a String object is computed as
s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
using int arithmetic, where s[i] is the ith character of the string, n is the length of the string, and ^ indicates exponentiation.
Wh ...