HashSet.remove() and Iterator.remove() not working

前端 未结 10 1527
借酒劲吻你
借酒劲吻你 2020-12-13 00:32

I\'m having problems with Iterator.remove() called on a HashSet.

I\'ve a Set of time stamped objects. Before adding a new item to the Set, I loop through the set, i

10条回答
  •  长情又很酷
    2020-12-13 00:58

    It's almost certainly the case the hashcodes don't match for the old and new data that are "equals()". I've run into this kind of thing before and you essentially end up spewing hashcodes for every object and the string representation and trying to figure out why the mismatch is happening.

    If you're comparing items pre/post database, sometimes it loses the nanoseconds (depending on your DB column type) which can cause hashcodes to change.

提交回复
热议问题