8. For each loop

I don't understand where the variable in the "for each loop" is initialized...e.g

for (Integer temperature : weeklyTemperatures) {

Where does the int temperature come from? It was not declared earlier..

Replace this line with your code.


Believe it or not, you are declaring the variable right then and there. The loop then loops over every weekly temperature and stores it in your variable (temperature) one by one.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.