Drag the edges to resize the window.

Code Editor

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 0.

Here is an example of accessing the element in the first position of the list:

ArrayList<Integer> quizGrades = new ArrayList<Integer>(); quizGrades.add(95); quizGrades.add(87); quizGrades.add(73); System.out.println( quizGrades.get(0) );

The example above will print out the grade value of 95.

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 get method.

Report a Bug
If you see a bug or any other issue with this page, please report it here.