@Ulf
Few explanations:
1.
> Intersting alternative, but I'm afraid, this is against the spec.
> Shifting all 0's to 1 would break String's hash definition: h = 31 * h +
> val[i++].
Yes it does, any way i think spec is to tight here. Do we really need
hash of each value even if String have length
Am 04.03.2010 19:33, schrieb Marek Kozieł:
Hello,
I would suggest:
public int hashCode() {
int h = hash;
if (h == 0) {
h = 0;
char[] val = value;
for (int i = offset, limit = count + i; i != limit; )
h = 31 * h + val[i++];