@Override
public int hashCode() {
int result = 17;
long double2long = Double.doubleToLongBits(weight);
result = 37*result + (int)(id ^ id>>>32); //long型 f ^ (f >>> 32)
result = 37*result + (active ? 0 : 1); //boolean型 f?0:1
result = 37*result + (int)(double2long ^ double2long >>> 32); // double 先转换long再按照long型转换
result = 37*result + age; //int,short,byte,char (int)f
result = 37*result + (int)sex;
result = 37*result + (int)ss;
result = 37*result + (int)bb;
return result;
}
public int hashCode() {
int result = 17;
long double2long = Double.doubleToLongBits(weight);
result = 37*result + (int)(id ^ id>>>32); //long型 f ^ (f >>> 32)
result = 37*result + (active ? 0 : 1); //boolean型 f?0:1
result = 37*result + (int)(double2long ^ double2long >>> 32); // double 先转换long再按照long型转换
result = 37*result + age; //int,short,byte,char (int)f
result = 37*result + (int)sex;
result = 37*result + (int)ss;
result = 37*result + (int)bb;
return result;
}
本文深入探讨了哈希代码生成算法的实现细节,包括如何将不同数据类型(如double、long、boolean、int等)转换为哈希值,并通过一系列操作确保生成的哈希值的唯一性和高效性。

被折叠的 条评论
为什么被折叠?



