publicinthashCode() { // The hash or hashIsZero fields are subject to a benign data race, // making it crucial to ensure that any observable result of the // calculation in this method stays correct under any possible read of // these fields. Necessary restrictions to allow this to be correct // without explicit memory fences or similar concurrency primitives is // that we can ever only write to one of these two fields for a given // String instance, and that the computation is idempotent and derived // from immutable state inth= hash; if (h == 0 && !hashIsZero) { h = isLatin1() ? StringLatin1.hashCode(value) : StringUTF16.hashCode(value); if (h == 0) { hashIsZero = true; } else { hash = h; } } return h; } //StringUTF16.java publicstaticinthashCode(byte[] value) { inth=0; intlength= value.length >> 1; for (inti=0; i < length; i++) { h = 31 * h + getChar(value, i); } return h; } //StringLatin1.java publicstaticinthashCode(byte[] value) { inth=0; for (byte v : value) { h = 31 * h + (v & 0xff); } return h; }