How to make HashMap work properly with custom key type?

后端 未结 3 2119
礼貌的吻别
礼貌的吻别 2020-12-11 17:10

I think my question is quite simple, however I couldn\'t find the solution so I decided to ask here. What i need is to make a HashMap with a custom Key type lik

3条回答
  •  悲哀的现实
    2020-12-11 17:33

    Your Pair class need to implement hashCode() and equals() according to the contract specified in the Javadoc for Object.

提交回复
热议问题