算法公式为:str[0]*31^(n-1) + str[1]*31^(n-2) + … + str[n-1]
java里 String hashcode的源码:
public int hashCode() {
int h = hash;
if (h == 0 && value. length > 0) {
char val[] = value;
for ( int i = 0; i < value. length; i++)<