Hello Java guys,
I have a problem. I keep getting a ClassCastException I don't understand. Let me tell you what happens:
Set<A> mySet = new HashSet<A>();
(filling mySet with objects of type A)
Now I want to order the Set:
Set<A> sortedSet = new TreeSet<A>(mySet);
BANG! ClassCastException in TreeMap.compare
I don't understand it. All the objects in mySet are of type A. Why could he be wanting to cast them anyway?
BTW, the toString() method of type A has been rewritten to return the member String name. If that has something to do with it.
Thanks for reading this,
pHew