Struck at 6/13 data sructure


#1




t


**Insert a new temperature of 111 at index 2.**

import java.util.ArrayList;

public class Temperatures {
	
	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(1,111);
    
    System.out.println( weeklyTemperatures.get(1) );
    
	}
}


#2

This java file's name is "TemepraturesB.java".

The name of the class and the Java file need to be the same:

public class TemepraturesB {/*Your Code*/}


#3

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