ManUnderground
Programmer
I'm running into a class cast exception when I call Arrays.sort and I'm not sure what exactly the trouble is. I have a TreeMap of Words which implement the Comparator interface. Word is an abstract class which spells compare and some abstract methods, extending it is WordSingleton. So the Tree has instances of WordSingleton in it. I then call:
Word[] words = myFrequencies.values().toArray(new Word[0]);
Arrays.sort(words);
In order to sort them (I know that the tree sorted them once but their state has changed and the order needs to reflect that). Now when I don't call sort everything works, even though I'm fairly certain the tree is calling compare, but when I call sort an error is thrown. Can somone shed some light on this snag for me?
Thanks in advance!
Word[] words = myFrequencies.values().toArray(new Word[0]);
Arrays.sort(words);
In order to sort them (I know that the tree sorted them once but their state has changed and the order needs to reflect that). Now when I don't call sort everything works, even though I'm fairly certain the tree is calling compare, but when I call sort an error is thrown. Can somone shed some light on this snag for me?
Thanks in advance!