File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes variable to string to command Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "variable to string to command" Watch "variable to string to command" New topic
Author

variable to string to command

donald croswell
Greenhorn

Joined: Mar 23, 2001
Posts: 6
Hey all,
I am trying to get a variable to concatinate to a string then use that string as a command like this:
newx = place + "[" + num + "]";
Where place = "ones" and num = "8".

So my line new line is:
newx = ones[8];
This will make newx equal to the static string array "ones" in the "8" place.
I can get the concatination to the string but it doesn't treat the string like a command.
Thanks for the help!
Don
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
Yes, all you did was assign the String value "ones[8]" to newx. You cannot use a String Object to represent a variable. If you want to assign the value in ones[8] to newx you have to use the variable name. If num is a String you'll have to convert it to an int first.

If places can hold other values besides "ones" you need to put this in a controll structure to determine which array to place it in.

------------------
Hope This Helps
Carl Trusiak, SCJP2


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: variable to string to command