"ArrayLists in Java are zero-indexed, which means that the first element in an ArrayList is at a position of 0."

The code example:

ArrayList quizGrades = new ArrayList();

System.out.println( quizGrades.get(0) );

Yet the correct code is " System.out.println( weeklyTemperatures.get(1) );"

So the correct way to choose the first in an index is "1" not "0"?


1 does not come before 0 and 0 is an index, so 0 is the first index.
Maybe you weren't meant to select the first index?

The main method is intended to look like:

public static void main(String[] args) {
    ArrayList<Integer> weeklyTemperatures = new ArrayList<Integer>();

And the exercise asks to use get to obtain the lowest temperature which is 67 which is at index 1.

However, adding the numbers in a different order makes the checkpoint behave poorly, as it doesn't actually check which is lowest and just assumes your code looks like above.


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