Is it possible in java make something like Comparator but for implementing custom equals() and hashCode()

前端 未结 8 1137
庸人自扰
庸人自扰 2020-11-27 03:50

I have an array of objects and I want to concatenate it with another array of objects, except that objects that have same id\'s. That objects are used in many places in the

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 04:32

    90% of the time when a user wants an equivalence relation there is already a more straightforward solution. You want to de-duplicate a bunch of things based on ids only? Can you just put them all into a Map with the ids as keys, then get the values() collection of that?

提交回复
热议问题