Java hashcode与collection 的关系

collection 类对象在调用remove,contains 等方法时需要比较对像是否相等,会涉及到hashcode,和equals.()方法

内容相等的两个对像其hashcode 值是相等的

equals()相等=》hashcode 相等反之不成立

猜你喜欢

转载自blog.csdn.net/qq_38662930/article/details/84146007