๐Ÿ“– Crammy ยท All study guides
AP Computer Science A ยท Unit 7

ArrayList: every key term you need

10 flashcard terms for AP Computer Science A Unit 7, written to match the course framework. Study them here, then drill them as interactive flashcards โ€” free, no account needed.

Study this unit free โ†’
ArrayList
Resizable array; grows/shrinks dynamically. ArrayList<Type> list = new ArrayList<>();. Type: Integer, String, custom classes.
ArrayList Methods
add(object): append. add(index, object): insert. remove(index): delete. get(index): access. size(): count. clear(): empty list.
ArrayList Type Parameter
<String> indicates ArrayList holds Strings. ArrayList<int> invalid (must use Integer). Generic type ensures type safety.
ArrayList Indexing
get(index) returns element; set(index, object) replaces. Index 0 to size()-1. Index out of range throws exception.
ArrayList vs Array
ArrayList: dynamic size, objects only, slower. Array: fixed size, primitives OK, faster. Choose based on needs.
Autoboxing/Unboxing
Automatic conversion: primitive โ†” wrapper class. int โ†’ Integer, double โ†’ Double. Enables primitives in generics.
ArrayList Iteration
For loop: for(int i=0; i<list.size(); i++) list.get(i). Enhanced for: for(String s : list). Iterator: while(it.hasNext()).
ArrayList Algorithms
Search: linear search with get(). Sort: Collections.sort(list). Min/max: Collections.min/max(list).
Removing Elements
remove(index): removes and shifts. remove(Object): removes first match. Modifying while iterating: use iterator.remove().
Unit 7 Summary
ArrayList dynamic, resizable. Methods: add, remove, get, size. Type parameter specifies element type. Autoboxing converts primitives.
Turn these into flashcards & quizzes โ†’

More AP Computer Science A guides