【发布时间】:2017-02-27 12:28:25
【问题描述】:
当我在以下语句中使用hashCode() 方法时:
System.out.println(obj.getClass().getName() + "@" +
Integer.toHexString(System.identityHashCode(obj)));
我得到这样的输出:
“联系@29453f441”
这对于每个单独的对象都是唯一的。覆盖hashCode() 会有什么影响?
【问题讨论】:
-
尝试使用 Set
并多次添加同一个对象.... -
集合的性能会有一些问题。 stackoverflow.com/questions/26674729/…
-
顺便说一句,这不是
hashCode()返回的内容。这就是toString()返回的内容。