I suggest using Map<String, Integer>
instead:
Create a map by completing
Map<String, Integer> values = new HashMap<String, Integer>();
Then change
int temp = 10;
to
values.put("temp", 10);
and access the value using
int tempVal = values.get(temp_name);
source share