Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to name a variable with a stringname?

Status
Not open for further replies.

Goku81

Programmer
Mar 27, 2001
34
US
This is what I want to do.....

String variableName = "polarBearTotal";

int (variableName) = 400;

// Is there a way to do something like that??
// please say there is. I'm tryin to save myself some
// work with vectors if there's already a way to do this.
// thanks
 
hi

whats ur exact problem? if u can xplain what u want to do exactly, may b i can help.

luv
Karthik.
A ship is safe in the harbour, but that's not what it is meant for!!! LOL
 
You can if you write a program that change place holders to names, i mean you redirect all your names to a file , generate a template source file with place holders for variable names, run a program that replaces place holders with names from that file. I hope u understand. R.Sathish.
babusats@rediffmail.com

 
Instead of a vector, use a HashMap. Then you can do something like this

HashMap hm = new HashMap();
hm.add ("PolarBearTotal", new Integer(400));

To get the number back, do this

Integer total = hm.get("PolarBearTotal");
int tot = total.intValue();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top