T
tomek milewski
Hello,
I can't solve some problem. I'm looking for mistake in my thinking or
any walkaround.
There is some sample code:
import java.util.TreeMap;
class A {
public A() {
}
public static final void main(String[] args) {
A a = new A();
TreeMap<A, Integer> map = new TreeMap<A, Integer>();
map.put(a, new Integer(1));
map.remove(a);
}
}
Executing last line of this code throws ClassCastException. Why element
can be putted into this TreeMap and can't be removed? I've been trying
some solutions but none has worked
.
Thank You for any answer.
I can't solve some problem. I'm looking for mistake in my thinking or
any walkaround.
There is some sample code:
import java.util.TreeMap;
class A {
public A() {
}
public static final void main(String[] args) {
A a = new A();
TreeMap<A, Integer> map = new TreeMap<A, Integer>();
map.put(a, new Integer(1));
map.remove(a);
}
}
Executing last line of this code throws ClassCastException. Why element
can be putted into this TreeMap and can't be removed? I've been trying
some solutions but none has worked
Thank You for any answer.