I think I may have found a bug in Java.
I have a TreeMap in which I use a custom comparator. However, it seems when I put(key, value), on a key that already exists, it does not override the key, thus creating duplicate keys. I think I have verified this because I tried:
System.out.println(testMap.firstKey().equals(testMap.lastKey()));
And this prints out true. Anyone know why this is happening?
This is the comparator code:
private class TestComp implements Comparator<String> {
@Override
public int compare(String s1, String s2){
if (s1.equals(s2)) {
return 0;
}
int temp = otherMap.get(s1).compareTo(otherMap.get(s2));
if (temp > 0) {
return 1;
}
return -1;
}