java 中的 hashCode()

简介

这是一个Object类定义的方法

tips

以前博客中提到的equal 如果采用 用户的id来判断是否相等,那么 hashCode 也要这么做。

public int hashCode() {
      return Objects.hash(name, salary, hireDay)
}
Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne
原文地址:https://www.cnblogs.com/eat-too-much/p/13395194.html