Convert String to Object - Newbie Question
- From: Marion <mchew02@xxxxxxxxxxx>
- Date: Fri, 28 Sep 2007 07:22:45 -0700
Hello all,
I am trying to convert a myString declared as a String[] and convert
it into an Object so that I can use the non static method.
Currently, my program does not compile. The error I'm receiving is my
old friend error msg: "non-static method setData....cannot be
referenced from a static content.
Essentially, I want to read in an array of Strings into objects for
data manipulation (a sort to be exact.).
The program looks something like this:
....
public void init (String[] array, int size){
..// assume array[0] is the first string read in from the text file
String dataString = array[0];
Node.setData(dataString);
....
}
Class Node {
(constructor stuff declared here)
}
...
public void setData(Object data){
this.data = data;
}
I read from the Java docs that String was an object (or was extended
by it) so doesn't that mean that String is an object? I'm beginning
to dislike objects! lol,
I know how to turn integers into objects with:
Integer one = new Integer(1);
why doesn't "String myString = new String (array[0]);:
work?
I tried to read documentation for java.io.Serializable (not sure if
that's what it's called but something like that) and on reflections.
being new to java, those documents I read scared the begeezus off of
me. (didn't understand em, nosiree)
I tried to use "stringToObject(string,class)" statement and sadly, I
am having trouble understanding how to use it in my program. There
are no examples anywhere.
All I want is to convert a string to object and it has gotten suddenly
complicated. :(
Ok, well it's 4am here, I'll try this again in the morning. :)
Anyone with hints or suggestions, please, I'm open to them.
-t
.
- Follow-Ups:
- Re: Convert String to Object - Newbie Question
- From: Roedy Green
- Re: Convert String to Object - Newbie Question
- From: Roedy Green
- Re: Convert String to Object - Newbie Question
- From: A. Bolmarcich
- Re: Convert String to Object - Newbie Question
- From: Hendrik Maryns
- Re: Convert String to Object - Newbie Question
- Prev by Date: Re: encrypted source file support in jdk?
- Next by Date: Re: Convert String to Object - Newbie Question
- Previous by thread: image loading problem in login page
- Next by thread: Re: Convert String to Object - Newbie Question
- Index(es):
Relevant Pages
|
|