Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 字符串情况下的哈希代码范围_Java_Netbeans_Hashcode - Fatal编程技术网

Java 字符串情况下的哈希代码范围

Java 字符串情况下的哈希代码范围,java,netbeans,hashcode,Java,Netbeans,Hashcode,我的代码中有字符串,出于某种目的,我取了它们的hashcode,但我想知道这些hashcode是否有任何范围,因为出现这种情况时,字符串的数量可能会超过hashcode的范围。那么hashcode的范围是什么呢?java中String类的hashcode方法是定义如下 public int hashCode() { int h = hash; if (h == 0) { int off = offset; char val[] = value;

我的代码中有字符串,出于某种目的,我取了它们的hashcode,但我想知道这些hashcode是否有任何范围,因为出现这种情况时,字符串的数量可能会超过hashcode的范围。那么hashcode的范围是什么呢?

java中
String
类的
hashcode
方法是定义如下

public int hashCode() {
    int h = hash;
    if (h == 0) {
        int off = offset;
        char val[] = value;
        int len = count;

            for (int i = 0; i < len; i++) {
                h = 31*h + val[off++];
            }
            hash = h;
        }
        return h;
    }
public int hashCode(){
int h=散列;
如果(h==0){
int off=偏移量;
char val[]=值;
int len=计数;
对于(int i=0;i

它总是对你的字符串有一些价值……所以,我不知道;我不认为你会用完hashCode的...

hashCode的范围是
int
的范围。对于任何所需的
hashCode()
,都有一个
String
,其中
hashCode

hashCode的范围是Integer.MIN\u值到Integer.MAX\u值。是的,大多数字符串和代码都是重复的。鸽子洞原理。