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

ClassCastException is occuring.

 
Huzefa Zohaib
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ClassCastException is occuring during execution of the following code.
Please solve this RunTimeError.

I am writing the object to the text file using the following code.
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Are you trying to create an User object and serialize it using the above code?
It won't work this way, because what you are actually creating in the above statement is a String object. So you will get a ClassCastException when you try to cast it into an User object.
Try the following code
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic