When does string caches it's hashcode? I found a lot of article saying, string caches it's hashcode during when we create a string literal. if this is true, then when we create a string object, why it's "hash" is showing 0? I think Once after the hashcode() method get called, the hashcode getting cached to the object header.
Can anybody clear my confusion? String hashcode is computed and getting cached during the object creation time or once the hashcode() get computed then only it's getting cached in the string object.
When we put an object on a map, during put operation the hashcode is getting calculated or it's been already calculated during the object creation, so just got used.
During debugging I found the actual string hash(string literal hash) and the hash which is getting stored in the hashmap bucket is different.So what's the logic behind that?