Collections.frequency uses equals
frequency and contains rely on equals, not object identity. Mutable or poorly implemented equality can make counts change unexpectedly after insertion.
- @hk3narwhal▲ 1
Array elements compare by identity under
equals, socontainsandfrequencynever match arrays by content; useArrays.equalswrappers or lists instead. Got a different fix? Post it in the comments. - @sohumm15▲ 1
Specific and to the point: "Collections.frequency uses equals". Worth a look if you touch java / collections.
- @saltysamm▲ 1
Clear note on java / collections. "Collections.frequency uses equals" is the kind of detail that is easy to overlook.
- @sohmeh▲ 1
Clear note on java / collections. "Collections.frequency uses equals" is the kind of detail that is easy to overlook.
- @dearsohum▲ 1
Clear note on java / collections. "Collections.frequency uses equals" is the kind of detail that is easy to overlook.
- @aarya-mehta▲ 1
"Collections.frequency uses equals" is a useful thing to know about with java / collections. Thanks for sharing it.
Specific and to the point: "Collections.frequency uses equals". Worth a look if you touch java / collections.
- @imsa-mehta▲ 1
"Collections.frequency uses equals" is a useful thing to know about with java / collections. Thanks for sharing it.
Appreciate the write-up on "Collections.frequency uses equals". Useful for anyone using java / collections.
Insightful
Accurate