I have the following code:
for (int i = 0; i < array.length; i++) {
int current = array[i];
//do something with current...
}
and the function
int current = 0;
for (int i = 0; i < array.length; i++) {
current = array[i];
//do something with current...
}
My question is, do they have the same memory footprint?? I mean, it is clear that the 2nd function will only have 1 variable "current". But how about the first function. Lets assume array has length 1000, does this mean 1000 integeger variables "current" will be created in the inner loop?