Convert a string to variable name
Hi.. I'm trying to make a forloop to get data for a specific variablename. The variablename changes each time it is run so.. My problem is that I cannot get use the string in the string array as the name of the variable which I like to get the value of. In this case int..
Here you get some of the code: (globals is just a file with global variables.. The names equal to the ones in this file to simplify )
publicstaticint idle = 0;
publicstaticint exit = 0;
String[] cycle ={"idle","exit"};// these is equat to the values defined
public ...{
while(Globals.exit != 1)
{
for (int i=0;i<cycle.length();i++)
{
****** PROBLEM *****if(Globals.(valueOf(cycle[i])) == valueOf(cycle[i]))
// I like to use the the string in cycle as a variable name.. Ex.. int test = idle ( int test = valueOf(cycle[i]) OR HOW IT SHOULD BE.. )
......
Somebody know how to do so..? And sorry for bad formulation, hard to decribe imo.. :S>

