in Java when I say.
String str= "abcd"; str.hashCode(); My question is When is Hashcode calculated? @ line 1 or @ line 2?
I am assuming , that hashcode is pre-computed. Whenever string is updated hashcode would also 'perhaps' update.
or its the other way i.e. every time you call str.hashCode() java computes its using the formula that's described here.
Stringinstance as String is immutable. What you will be able to do is create a new instance and assign it to the same variable.