Data Structures 5/13


#1

Stuck at exercise 5/13. Link : https://gist.github.com/2e406fa349d3cb0d81702cf2cbdbab41

My code displays the output of 67, which is the lowest temperature in the arraylist, but the error keeps coming up “did you print the lowest temperature?”

The exercise does not let me move on but Im sure my code is correct.


import java.util.ArrayList;

public class Temperatures {
	
	public static void main(String[] args) {
/*create arraylist object weeklyTemperatrues of class type Integer(whole number)
*/
ArrayList<Integer> weeklyTemperatures = new ArrayList<Integer>();
    /*adding integers 78, 67, 89, 94 to the arraylist. calling method add on arraylist object weeklyTemperatures
    */
    weeklyTemperatures.add(78);
    weeklyTemperatures.add(67);
    weeklyTemperatures.add(89);
    weeklyTemperatures.add(94);
    
    //using get method to print lowest temp in weeklyTemperatrues

    System.out.println(weeklyTemperatures.get(1));
	

    
	}
}



#2

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