4.7 - Iterating over an ArrayList - Why is this code not satisfactory?


#1




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

	}
}


#2

You will have to make up your mind
weeklyTemperature
weeklyTemperatures
weeklytemperature


#3

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