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

ClassCastException  RSS feed

 
geet kaur
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To sort things, you need to compare them. Can you compare Integers with Strings or Booleans ? Look at the API for Arrays#sort(Object[]). That's what they mean by "all elements in the array must be mutually comparable".
 
Ankit Garg
Sheriff
Posts: 9608
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it's because your array is of type Object. and object doesn't implements comparable. Although the elements are all comparable, but not to each other....
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it's because your array is of type Object.

It would be fine is the content of the array would be comparable to each other. Like :
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!