Where did this element/integer come from? [8/13]


#1



https://www.codecademy.com/courses/learn-java/lessons/data-structures/exercises/for-each-loop?action=lesson_resume


I am confused as to where in this peice of code did we specify what 'temperature' is. Where did the int temperature come from? I mean this is a computer it cannot, ofcourse, understand that weekly temperatures are related to temperatures.


Replace this line with your code.


#2

Hey!! @bytemaster17204 :slight_smile:
Fun username and I would definitely understand your confusion. When you're looping through a data structure, that ArrayList, it needs a variable or placeholder to loop through each individual element! That variable 'temperature' are the actual individual elements and weeklyTemperatures is just obviously the ArrayList.

-> int Temperature: actual ELEMENTS

-> weeklyTemperature: the DATA STRUCTURE

Hope this helps you


#3

Thanks. However the issue has not been completely resolved.
Where was it that we specified that temperature are the actual elements? (I dont remember doing so anywhere in this part of lesson series).


#4

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