@Override public int hashCode() { int result = 17; result = result * 31 + areaName.hashCode(); result = result * 31 + areaId.hashCode(); return result; } 可以用移位和减法来代替乘法,以获得更好的性能:31 * i == (i << 5) - i
java重写hashcode方法使用31的原因
最新推荐文章于 2023-03-30 11:14:59 发布