• Post Reply Bookmark Topic Watch Topic
  • New Topic

ClassCastException?  RSS feed

 
Ranch Hand
Posts: 40
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the following code throws a ClassCastException:



But I am not sure how it does.
Is it because m1() returns an object, and an Object is not a String, so therefore you cannot convert it into a String?
 
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but be careful when using the word "convert". Casting is not converting.
 
Eric Longhorn
Ranch Hand
Posts: 40
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, thanks.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!