| Author |
Incompatible types! Into array.
|
g Peshone
Ranch Hand
Joined: Oct 20, 2008
Posts: 44
|
|
How would I convert string into an object to I can inserted into array? Thanks
|
 |
Paul Yule
Ranch Hand
Joined: May 12, 2008
Posts: 229
|
|
Originally posted by g Peshone: How would I convert string into an object to I can inserted into array?
If you only want the name of the Body to be inserted into the Array you can use a String array instead of your SolBody type Array. Otherwise you could just insert the whole object into your array instead of the name. [ October 22, 2008: Message edited by: Paul Yule ]
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24057
|
|
i.e., bodies[0] = sun;
|
[Jess in Action][AskingGoodQuestions]
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
Your array is declared to hold references to instances of SolBody, and a String is not a SolBody. It looks to me like you just want to add "sun" to the array, bodies[0] = sun; (Also, it looks like "nameFor" is already a String, so calling toString() on nameFor isn't necessary.)
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
g Peshone
Ranch Hand
Joined: Oct 20, 2008
Posts: 44
|
|
Thanks, that works, I thought I could go thru with a generic �field� name but then I could not increment it in the next step to insert next name. Thanks
|
 |
 |
|
|
subject: Incompatible types! Into array.
|
|
|