不重写hashCode()和equals()情况下:
对象相等,则调用hashCode()的值一定相等
hashCode相等,则对象不一定相等
若重写了hashCode()方法:
对象相等,hashCode()可能相等,可能不相等,但是我们一般在重写hashCode()方法时保持hash值相等
不重写hashCode()和equals()情况下:
对象相等,则调用hashCode()的值一定相等
hashCode相等,则对象不一定相等
若重写了hashCode()方法:
对象相等,hashCode()可能相等,可能不相等,但是我们一般在重写hashCode()方法时保持hash值相等