Iterating over an ArrayList - 7/13


<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>
Use the example to help you create the for loop and use the get method. error: ‘)’ expected
for (int j = 0; j < weeklyTemperatures.size(); j++ {
^ error: reached end of file while parsing
2 errors


import java.util.ArrayList;

public class TemperaturesC {

public static void main(String[] args) {

	ArrayList<Integer> weeklyTemperatures = new ArrayList<Integer>();
	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>

is syntax error, you forget two things,
1- ) in after j++
2- close block by } in for or void main()

You are forgetting a closing-parentheses-) in the definition of your FOR-loop

google search
== the Book ==
java [your question]

1 Like
       Thank you so much, @leonhard.wettengmx.n! Sometimes, there are little mistakes I don't notice. Probably not something i want to maintain if I want to work at Google one day!

It may be helpful

I have the same code as you and it is not working for me. What should I do?

You can wait some days and then try again inputting same code to the
system. Though I don’t know whether it is solution or not. But believe me,
I did same things when I found such case in codeacademy systems. Best of

Thanks will tell you when I passed the level

Can anyone explain why we added .size in
for (int j = 0 ; j < weeklyTemperatures.size(); j ++) {
System.out.println(weeklyTemperatures.get(i) );

what does it mean ?

Thank you

It is only possible after completing level.

It seems very impossible it could be a bug

look closer that the variables you are using, ask yourself where are you getting the “i” variable from?

you use .size to tell that “j” will be compared against the size of the array… so if the array has 5 spaces, you are sayingt hat you want to be sure “J” is smaller than 5 which is the value of “Size” but the idea is to use something that will just say “compare this agains whatever the current size is…”