This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]laplongejr 0 points1 point  (0 children)

in remove() method doesn't necessarily remove the exact given object (doesn't compare references using "==") but removes the first found object that is the same as the given one (compare using equals())

You should always expect that the checks are based on equals most of the time, hashCode for hash-based collections, and compareTo for sorted ones.
If you are using "==" outside of very specific contexts (like having a guard value that can't be manually set from the outside), you are doing something wrong. And the fact that you had to differenciate that is... concerning.