Code
int[] myIntArray = new int[10];
for(int i=0; i < 10; i++) {
myIntArray[i] = i*10;
}
for(int i=0; i<10; i++) {
System.out.println("Element " + i + ", value is " + myIntArray[i]);
}
I'm not sure how it's printing out the value of i*10 in second for loop... as they are in seperate scopes..... So it should just be printing out value of i:0,1,2,3,4,5,6,7,8,9.
As they are seperate for loops, in seperate scopes.... YET, it's still printing value of i*10 for some reason, which i don't understand.
For example, if i put a System.out.println(i);, in between the for loops it doesn't work, cuz it's out of scope....
Therefor the 2nd for loop shouldn't get value of i*10