I’m wondering how I do the following. Make 10 int variables called, var_0, var_1, var_2, etc.
All holding 0. I’m picturing something like this…
for(int i=0;i>10;i++){
int var_i = 0;
}
But of course it doesn’t work. How do I make this work without doing every single variable manually?
It’s intended for an arbitrary amount of variables.
It’s impossible in Java, there are no macros that would let you do it. Usually if you need 10 variables with same name you just use array.
It will be initialized to zeroes by default.
If you don’t know number of elements in advance you can declare array and construct it later: