8.For each loop Where the heck did the integer temperature come from?


Ok so I understand the code:

import java.util.ArrayList;

public class TemperaturesForEach {
public static void main(String[] args) {

	ArrayList<Integer> weeklyTemperatures = new ArrayList<Integer>();
	**!*//    for (Integer temperature : weeklyTemperatures) {    \\*!  This LINE???  Integer temperature hasn't been staed anywhere yet the code works???**





To answer your question . Read this article by Oracle


Think of temperature as a variable which takes on the value of each element in your ArrayList and moves on to the next value every iteration(run of the loop).

So the first iteration temperature would be 78 , next iteration temperature would be 67 and so on and so on.