Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ClassCast Exception while using TreeSet

 
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