1

String hashCode implementation in java 11 looks like this:

 public int hashCode() {
        int h = hash;
        if (h == 0 && value.length > 0) {
            hash = h = isLatin1() ? StringLatin1.hashCode(value)
                                  : StringUTF16.hashCode(value);
        }
        return h;
    }

Why do we need int h here ? Is it somehow related to thread synchronization ?

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
  • My question is a duplicate of other 2 topics but that topics are not duplicates of each other - interesting – gstackoverflow Sep 19 '19 at 15:19
  • 1
    @gstackoverflow I think they should be (and you can help that by voting on a close reason of the first one). – Suma Sep 19 '19 at 16:04

0 Answers0