• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to convert a String type to a generic class type?  RSS feed

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I have a String repersentaion of some Object.I want that object convert back into some class type how can I do this?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kishor Joshi wrote:
I have a String repersentaion of some Object.I want that object convert back into some class type how can I do this?


Well, that would depends on (1) what that string representations is? and it also depends on (2) what the object of what class type to do want?

Henry
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no general, automatic way to do this. You'll have to parse whatever is in the string and initialize a new object with the data that you've parsed from the string.
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As it says in our FAQ, you should avoid turning Objects to Strings or vice versa is at all possible.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!