Is it possible to create a method that can create objects named by String?
private static int a = 0;
public static void CreateNew() {
Object ("number" + a) = new Object();
a++;
}
If you know, how would I do it?
Is it possible to create a method that can create objects named by String?
private static int a = 0;
public static void CreateNew() {
Object ("number" + a) = new Object();
a++;
}
If you know, how would I do it?
It makes more sense to use a java.util.Map / HashMap in this case.
Map<String,String> strMap = new HashMap<String, String>();
strMap.put("number" + a, "value_for_this_string");
Java is a compiled language and not an interpreted language like the scripting languages where you can do something like this straightforward.