Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ClassCast Exception while using TreeSet  RSS feed

 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Above code throws ClassCastException at line 6.
i know that for TreeSet its elements should be mutally comparable.
if i replaces Comparator with Comparable then class
compiles and runs fine but elements doesnot sorting.

I am not able to understand why
thanks.
 
wise owen
Ranch Hand
Posts: 2023
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!