Unit 4 Cycle 1 Day 26: Array vs ArrayList Comparison

Unit 4 Foundation (Cycle 1) Day 26 of 28 Foundation

Array vs ArrayList Comparison

Section Mixed — Review: Collections

Key Concept

Arrays and ArrayList have different strengths. Arrays have fixed size, use bracket notation (arr[i]), store primitives directly, and have a length property. ArrayList has dynamic size, uses method calls (list.get(i)), only stores objects (autoboxing handles primitives), and has a size() method. Choose arrays when the size is known and fixed; choose ArrayList when the size may change. The AP exam tests your understanding of when each is appropriate.

Consider the following statements about arrays and ArrayLists.

I. Arrays have a fixed size; ArrayLists can grow. II. Arrays can hold primitives; ArrayLists cannot. III. Both arrays and ArrayLists use zero-based indexing.

Which statements are true?

Answer: (B) I, II, and III

I: TRUE. Array size is fixed. ArrayList resizes.
II: TRUE. Arrays hold int, double. ArrayList uses Integer, Double.
III: TRUE. Both start at index 0.

Why Not the Others?

(A) III is also true.

(C) II is also true.

(D) I is also true.

Common Mistake

ArrayList uses autoboxing for primitives. ArrayList is invalid. Use ArrayList.

AP Exam Tip

Array: fixed size, primitives ok, uses []. ArrayList: dynamic size, wrapper types only, uses get/set/add/remove.

Review this topic: Section Mixed — Review: Collections • Unit 4 Study Guide
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.