I have a string containing the variable name. I want to get the value of that variable.
int temp = 10;
String temp_name = "temp";
Is it possible to access the value 10 by using temp_name?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I suggest that you use a
Map<String, Integer>instead:Create the map by doing
Then change
to
and access the value using