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

前端 未结 8 1143
庸人自扰
庸人自扰 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:21

    Would using a TreeSet help here? A TreeSet actually performs ordering and Set based behavior using compare/compareTo and allows you to define a custom Comparator for use in one of the constructors.

提交回复
热议问题