在
hashCode的
ArrayList是一个功能
hashCode都存储在该元件S1
ArrayList,所以当容量的变化,它的变化当添加或删除元素或改变其的hashCode办法元素发生变异一个它不会改变。
这是Java 8实现(实际上是在中实现的
AbstractList):
public int hashCode() { int hashCode = 1; for (E e : this) hashCode = 31*hashCode + (e==null ? 0 : e.hashCode()); return hashCode;}顺便说一句,这是出现在
hashCode()该
List接口的Javadoc中的确切代码:
int java.util.List.hashCode()
返回此列表的哈希码值。列表的哈希码定义为以下计算的结果:
int hashCode = 1;for (E e : list) hashCode = 31*hashCode + (e==null ? 0 : e.hashCode());



