When using a TreeMap object, when you call the TreeMap put method
put (key, value)
If there is already an entry with the specified key, the old value for
that key is supposed to be replaced by the new value.
The code to do so in src/share/classes/java/util/TreeMap.java has a
bug that causes this not to happen. The code is in the setValue method
of the Entry inner class (about line 854). It now reads:
public Object setValue (Object v) {
Object oldValue = this.value;
this.value = value;
return oldValue;
}
but it should read:
public Object setValue (Object v) {
Object oldValue = this.value;
this.value = v;
return oldValue;
}
I think this serves as a perfect demonstration of why you should name
member variables something that is not likely to get used in the code
as an argument or automatic. Like many organizations, we have adopted
the convention of using an "m_" prefix for member variables.
put (key, value)
If there is already an entry with the specified key, the old value for
that key is supposed to be replaced by the new value.
The code to do so in src/share/classes/java/util/TreeMap.java has a
bug that causes this not to happen. The code is in the setValue method
of the Entry inner class (about line 854). It now reads:
public Object setValue (Object v) {
Object oldValue = this.value;
this.value = value;
return oldValue;
}
but it should read:
public Object setValue (Object v) {
Object oldValue = this.value;
this.value = v;
return oldValue;
}
I think this serves as a perfect demonstration of why you should name
member variables something that is not likely to get used in the code
as an argument or automatic. Like many organizations, we have adopted
the convention of using an "m_" prefix for member variables.