<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>
<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-java/lessons/data-structures/exercises/arraylist-iterating?action=lesson_resume&link_content_target=interstitial_lesson
Hey All, I just have a general question about the get method. The exercise wouldn’t let me pass until I added the argument j to the get method, but isn’t j just serving as a counter for the ‘for’ loop? Why does it affect what indices are being accessed?
```import java.util.ArrayList;
public class TemperaturesC {
public static void main(String[] args) {
ArrayList<Integer> weeklyTemperatures = new ArrayList<Integer>();
weeklyTemperatures.add(78);
weeklyTemperatures.add(67);
weeklyTemperatures.add(89);
weeklyTemperatures.add(94);
weeklyTemperatures.add(2, 111);
for (int j = 0; j < weeklyTemperatures.size(); j++) {
System.out.println( weeklyTemperatures.get(j));
}
}
}
<do not remove the three backticks above>