Java - TreeSet and hashCode()

前端 未结 4 1321
我在风中等你
我在风中等你 2020-12-03 14:20

I have a quick question about TreeSet collections and hashCode methods. I have a TreeSet and I\'m adding objects to it, before I add an object, I check to see i

4条回答
  •  天命终不由人
    2020-12-03 14:37

    From Java Doc:

    If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.

    Means: the objects you use for hashing are not equal.

提交回复
热议问题