hashCode()方法是什么,hashCode相同代表什么?
想知道hashCode是什么,就必须先了解一下什么是哈希Hash.简单来说Hash就是把任意长度的数据变成固定长度的数据.想详细了解一下的也可以参考我另一篇Blog什么是Hash哈希
所以Java中就默认地定义了Hash函数来获取一个hashCode.我们可以看看Java中hashCode()的原码
/**
* Returns a hash code for this string. The hash code for a
* {@code String} object is computed as
* <blockquote><pre>
* s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
* </pre></blockquote>
* using {@code int} arithmetic, where {@code s[i]} is the
* <i>i</i>th character of the string, {@code n} is the length of
* the string, and {@code ^} indicates exponentiation.
* (The hash value of the empty string is zero.)
*
* @return a hash code value for this object.
*/</