in normal for loop, we could do multiple variable declarations & limit their scope within the loop
eg: if I have an ArrayList myList of
for(int i=0, j=5 ; i <myList.size() ; i++, j--)
now i & j’s are limited to loops scope
Can we do something similar with for-each // limit scope to loop & also change its value each iteration
for (Integer value : myList) {
}
you will still have access to them in the scope outside the for, but you can’t initialize them inside the for either :/