ARRL - Traversing ArrayList (Lesson)

APCompSci_LessonTopBanner.png

Traversing ArrayList

Introduction

When accessing the elements of an ArrayList loops can be used just as they are used with arrays. The challenge comes when you are asked to insert or delete elements in an ArrayList. Since the ArrayList is mutable and the size can change you have to be extra careful with the loop counter to account for skipping values or trying to access an index that no longer exists. As you work through different ArrayList looping algorithms pay close attention to the loop counter, the size of the ArrayList, and the position of the elements.

Click below to learn more about Traversing ArrayLists.

 

Book Icon Click on "Runestone Academy" below to open the required reading that is listed.

Runestone Academy: AP CSA – Java Review Links to an external site.

  • READ: 9.13 – Removing an Object at an Index
  • READ: 9.14 – Looping through a List

Try It Icon Complete the Word Pair Free Response Question below. Write your code on a sheet of paper.

Free Response Question from Collegeboard website Links to an external site..

 

Check your answers!

Once you have written your solutions. View the two videos below to check your work.

 

 

Try It Icon Complete Part B of the Digits Free Response Question. Write your code on a sheet of paper.

(Recall that you completed Part A in a previous lesson.)

Free Response Question from Collegeboard website Links to an external site..

 

Check your answer!

Once you have written your solutions. View the video below to check your work.

 

ArrayList Practice

Click below to begin the ArrayList Practice activity.

 

Practice Icon Practice-It! Practice

1.Go to the PracticeIt website Links to an external site..

2.Log into account.

3.Click on Start Practicing!

4.Go to the most recent edition.

5.Click on Chapter 10: ArrayLists.

6.Complete Exercises 10.2 – 10.17.

APCompSci_LessonBottomBanner.pngIMAGES CREATED BY GAVS