Click here to navigate the course.

Drag the edges to resize the window.

In Projects, you can keep track of your progress as you go throught the tasks. Check each item as you complete it!

Code Editor

Earlier in this lesson, we learned about the for loop. Since we've also learned how to retrieve the value at a specific index of an ArrayList, we can now access each of the elements.

for (int i = 0; i < quizGrades.size(); i++) { System.out.println( quizGrades.get(i) ); }

In the example above, the for loop above includes the following statements:

  1. Initialization: int variable i is set to 0 which is the first index of an ArrayList.
  2. Test condition: the code in the block will run as long as i is less than the size of quizGrades.
  3. Increment: The code in this block will execute after each loop. In this case,i will increment by 1 with i++ after each loop.

The size method returns an int that represents how many total elements are stored within quizGrades. The example will print out each element within quizGrades in order. The process of going through each element in the ArrayList is called iteration.

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