Use the get method to print out the temperature 89

guys please help me ,i can’t figure it out what is wrong with my code and why is saying me that the index is not ok

import java.util.ArrayList;

public class TemperaturesB {
	public static void main(String[] args) {

		ArrayList<Integer> weeklyTemperatures = new ArrayList<Integer>();
    weeklyTemperatures.add(2, 111);
    System.out.println( weeklyTemperatures.get(2) );
   System.out.println( weeklyTemperatures.get(3) );

[78, 67, 111, 89, 94]

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