Geting a variable from a String
Hi, i need to get a variable from a string. For example:
..............
int test1;
int test2;
int test3;
.........
int test = getvariablefromstring("test"+3);
..................
Hi, i need to get a variable from a string. For example:
..............
int test1;
int test2;
int test3;
.........
int test = getvariablefromstring("test"+3);
..................
Reflection will work for member variables, not locals. It'sprobably not the right solution for you though.
If you just want test1, test2, test3, ... testN, then you want an array or a List.
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html
http://java.sun.com/docs/books/tutorial/collections/