Java hashCode() 方法
hashCode() 方法用于返回字符串的哈希码。
字符串对象的哈希码根据以下公式计算:
s[i] 是字符串的第 i 个字符,n 是字符串的长度,^ 表示求幂。空字符串的哈希值为 0。
public class Test {
public static void main(String args[]) {
String Str = new String("www.runoob.com");
System.out.println("字符串的哈希码为 :" + Str.hashCode() );
}
}