How does the JVM ensure that System.identityHashCode() will never change?

前端 未结 5 928
终归单人心
终归单人心 2020-11-29 00:33

Typically the default implementation of Object.hashCode() is some function of the allocated address of the object in memory (though this is not

5条回答
  •  离开以前
    2020-11-29 00:49

    In answer to the second question, irrespective of the implementation, it is possible for multiple objects to have the same identityHashCode.

    See bug 6321873 for a brief discussion on the wording in the javadoc, and a program to demonstrate non-uniqueness.

提交回复
热议问题