Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ClassCast Exception

Status
Not open for further replies.

ManUnderground

Programmer
Feb 21, 2007
1
US
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!
 
Maybe if you post the stacktrace for the exception and the actual code where it's being thrown we can help you.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top