Hi!
There is something that I don't understand about hashCode method as it is defined in class Object.
Documentation from SUN says:
"The general contract of hashCode is:
Whenever it is invoked on the same object more than once during an execution of a
Java application, the hashCode method must consistently return the same integer..."
Then it continues:
"As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer..."
What I don't understand is what happens if an object changes its place (address) in memory (for example garbage collector moves it in an other place). Will the hash code for that object still be the same? I know that I can override hashCode method in my class, but what happens with java.lang.Object.hashCode(), i.e. when I don't override? Will it still return the same value as before? If so, how?
Thank in advance to anyone who answers this question.