AP Computer Science A · Lesson 4.9 · Unit 4 · CED topic 4.9

ArrayList traversals and deleting safely

Name:   Date:  

1 Why this lesson matters

Read the opening paragraph and the "Required content" box on the lesson page. In your own words, explain each objective below.

9.A. Develop code used to traverse the elements of an ArrayList and determine the results of these traversals.

2 The two loops

Read this section. In your own words, summarize the main idea.

3 Deleting during a traversal

Read this section. In your own words, summarize the main idea.

4 Do not resize inside an enhanced for loop

Read this section. In your own words, summarize the main idea.

5 Worked example

Read the "Worked example" box. Then, without looking back, try writing your own answer below.

Trace the forward removal loop on [3, 3, 7], removing every 3.

6 Exam focus: avoid this mistake

Read the "Exam focus" box, then restate it in your own words.

7 Sum it up

In two or three sentences, explain this lesson's main idea to someone who has not read it.