Java, Object.hashCode() result constant across all JVMs/Systems?

前端 未结 6 1371
傲寒
傲寒 2020-12-05 21:17

Is the output of Object.hashCode() required to be the same on all JVM implementations for the same Object?

For example if \"test\".hashCode()

6条回答
  •  醉话见心
    2020-12-05 22:02

    No, the result of hashCode() is only constant during a single execution. You should not expect the result of the function to be the same between executions, let alone between JRE versions or platforms.

提交回复
热议问题