Great! Now we can start accessing the temperatures that our ArrayList stores.
We can access the elements of
weeklyTemperatures by using an element's index, or position, in the list.
An element's index refers to its location within an ArrayList. ArrayLists in Java are zero-indexed, which means that the first element in an ArrayList is at a position of
Here is an example of accessing the element in the first position of the list:
ArrayList<Integer> quizGrades = new ArrayList<Integer>();
System.out.println( quizGrades.get(0) );
The example above will print out the grade value of
The index of the element containing the value
95 is at position
0 in the ArrayList. We access the value by providing its index to the