Possible Duplicate:
Use a variable within a variable? Java
Hi this is a general programming related question more so than a java question. If i have a program like this :
public class tester {
public static void main(String[] args) {
int i = 2;
String text = "Hello";
String text2 = "world";
System.out.println(text);
System.out.println(text + i);
}
}
I want to print "hello", then "world" but instead i print "hello" and then "hello2". is there anyway i can access the variable text2 by appending the counter i to the variable test? I need a solution for this for a much more complicated program i am working on
Thanks, Matt