Exercise 7 not working/whats wrong?

Hello, i’m stuck on exercise 7, i wrote it all perfectly, but it keeps giving me the following error:

TemperaturesC.java:13: error: cannot find symbol
     for (int j = 0; i < weeklyTemperatures.size(); j++) {
  symbol:   variable i
  location: class TemperaturesC
1 error

My code so far is:

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; i < weeklyTemperatures.size(); j++) {
  System.out.println( weeklyTemperatures.get(j) );

Thanks in advance.

Your error message is telling you that you have told Java to do something with a variable called i but i has not been defined. Why did you choose i < weeklyTemperatures.size() as the condition for ending your for loop?

Well ■■■■ me. Didn’t notice that, it was the only thing keeping the code from working.

Its been a while since i’ve worked with programming, gotta brush up my reading/perception skills again.

1 Like

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