Convert String to Object - Newbie Question



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

.



Relevant Pages

  • Re: OO conventions
    ... subclass object (likely by passing a string to the constructor, e.g., ... Image.opendefined as a static method (wait...is that ...
    (comp.lang.python)
  • Re: Can i pass a SqlConnection object with opened connection to a method/function as a parameter?
    ... methods in your long concatenated string, ... DataTools.EscapeMask method (a static method, apparently), or the ... > connection and what you do with it when you get it ... >> the existed opened sqlconnection object to do it and pass the object to ...
    (microsoft.public.dotnet.framework)
  • Re: Accessing functions defined in Global.asax
    ... Anjali Lourda wrote: ... > public function getNameas String ... better off creating a class with a static method and referencing the ... Ryan Walberg, B.Sc., MCSD, MCSD for .NET ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Inheritable Static methods
    ... Any static method, ... classname to a string, without hardcoding a string. ... encapsulate it into the class itself, so that instead of having the ... the former encapsulates the conversion into the int type. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Convert Delphi to C#
    ... The closest you can get to a Delphi function in C# would be a non-void ... C# static methods are pretty much the same as Delphi class methods. ... class function InsertClassNameHere.test(param: string): string; ...
    (microsoft.public.dotnet.languages.csharp)