Please explain the hashCode of the java.lang.String.

Posted by kunjaan on Stack Overflow See other posts from Stack Overflow or by kunjaan
Published on 2010-04-30T03:09:15Z Indexed on 2010/04/30 3:17 UTC
Read the original article Hit count: 347

Filed under:
|
|

What is the significance of the hashCode used inString?

   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;
}

© Stack Overflow or respective owner

Related posts about java

Related posts about hashcode