Will .hashcode() return a different int due to compaction of tenure space?

前端 未结 5 1714
谎友^
谎友^ 2020-12-01 01:24

If I call the Object.hashcode() method on some object it returns the internal address of the object (default implementation). Is this address a logical or phys

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 02:03

    In this link it says that indeed the default hash code is the JVM address of the object, but if it is moved - the address stays consistent. I don't know how reliable this source is, but I am sure that the implementors of this method thought of this scenario (which is not rare or corner case), and ensured correct functionality of this method.

提交回复
热议问题