为何要复写equals()的同时最好复写hashcode()

咱们都知道全部的类都从Object继承了equals()和hashcode(),先来看看equals(),和hashcode()在Object中的实现: public boolean equals(Object obj) { return (this == obj); } public native int hashCode(); 能够知道equals比较的实际是引用的地址
相关文章
相关标签/搜索