I am wondering, from perspective of memory usage, performance and clean code, is it better to initialize variable inside or outside the loop. For example, below I show two options using variable myInt in a for loop.
Which options is better? I have a intuition on which option does what, but I want a true "Java" clarification which option is better for 1) Performance, 2) Memory and 3) Better code style.
Option 1:
int myInt = 0;
for (int i =0; i<100; i++){
some manipulation here with myInt
}
Option 2:
for (int i =0; i<100; i++){
int myInt = 0;
some manipulation here with myInt
}