一、根据HashMap源码,我们需要重写: 1、hashcode static final int hash(Object key) { int h; return (key == null) ? 0 : (h = key.hashCode()) ^ (h >>