Java HashSet is allowing dupes; problem with comparable?

Posted by IVR Avenger on Stack Overflow See other posts from Stack Overflow or by IVR Avenger
Published on 2010-06-02T20:28:22Z Indexed on 2010/06/02 20:34 UTC
Read the original article Hit count: 266

Filed under:
|
|

Hi, all.

I've got a class, "Accumulator", that implements the Comparable compareTo method, and I'm trying to put these objects into a HashSet.

When I add() to the HashSet, I don't see any activity in my compareTo method in the debugger, regardless of where I set my breakpoints. Additionally, when I'm done with the add()s, I see several duplicates within the Set.

What am I screwing up, here; why is it not Comparing, and therefore, allowing the dupes?

Thanks,
IVR Avenger

© Stack Overflow or respective owner

Related posts about java

Related posts about sets