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 ?

2
  • My question is a duplicate of other 2 topics but that topics are not duplicates of each other - interesting Commented Sep 19, 2019 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). Commented Sep 19, 2019 at 16:04

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.