I am working on an android application and I need to create some variables at runtime.
I try this…
for (int i = 0; i < 10; i++) {
String var+i = "number is: " + i;
}
I thought I can set name of variable like this (var+i) but this is not allow because arithmetic symbols are not allow in variable name.
Is there any way to do this, I want to create some variables at runtime.
You can’t create a variable name like that at all. If you only care about being able to generate a bunch of variables and don’t care what the name actually is, then consider an array large enough for the most you think you’ll want, or a Vector if you just don’t know how many.