What this deck covers
This deck focuses on Arraylist Traversals, giving you a quick way to review the definitions, rules, and examples that matter most for AP Computer Science a.
Study Arraylist Traversals in AP Computer Science a with focused flashcards that help you recognize the idea, recall the key rule, and apply it in practice-style prompts.
0% Complete
Find the syntax to initialize an empty ArrayList of integers.
Tap card or press Space to flip
ArrayList list = new ArrayList<>();. Creates new empty ArrayList with Integer type parameter.
How well did you know it?
Card 1 / 78
Space to flip · ← / → to move · once flipped, → Got it · ← Still learning
This deck focuses on Arraylist Traversals, giving you a quick way to review the definitions, rules, and examples that matter most for AP Computer Science a.
Work through these flashcards in short sessions. Try to answer each prompt before flipping the card, then revisit any cards you miss until the explanation feels automatic.
Answer: ArrayList list = new ArrayList<>();. Creates new empty ArrayList with Integer type parameter.
Answer:
Answer: Collections.sort(arrayList). Sorts elements using their natural comparison order.
Answer: Iterator loop. Uses Iterator object for controlled sequential access.
Answer: Iterator loop. Uses Iterator object for controlled sequential access.
Answer: ArrayList.size(). Returns number of elements currently stored in the list.
Answer: int. Returns integer count of elements in the ArrayList.
Answer: for (Integer num : arrayList) { }. Enhanced for loop iterates through each Integer in the list.
Answer: ArrayList.toArray(). Converts ArrayList to standard array format.
Answer: ArrayList.iterator(). Returns Iterator object for traversing the ArrayList.
Answer: ArrayList.retainAll(collection). Keeps only elements present in both collections.
Answer: for (Integer num : arrayList) { }. Enhanced for loop iterates through each Integer in the list.
Answer: IndexOutOfBoundsException. Runtime exception for accessing non-existent index positions.
Answer: int. Returns integer count of elements in the ArrayList.
Answer: ArrayList.add(element). Appends element to the end of the list.
Answer: O(n). Requires shifting all subsequent elements leftward.
Answer: ArrayList.clear(). Removes all elements, making the ArrayList empty.
Answer: For-each loop. Enhanced for loop simplifies iteration without index management.
Answer: ArrayList.add(index, element). Inserts element at specified position, shifting existing elements.
Answer: ArrayList.replaceAll(unaryOperator). Applies function to transform each element in place.
Answer: To access each element in the ArrayList. Allows examination or processing of every element sequentially.
Answer: for (String s : arrayList) { System.out.println(s); }. Enhanced for loop prints each string element sequentially.
Answer: ArrayList.remove(element). Searches and removes first matching element found.
Answer: ArrayList list = new ArrayList<>();. Creates new empty ArrayList with Integer type parameter.
Answer: break. Immediately exits loop when condition is met.
Answer: ArrayList.size(). Returns number of elements currently stored in the list.
Answer: n−1. Last index equals size minus one due to zero-based indexing.
Answer: ConcurrentModificationException. Thrown when modifying ArrayList during iteration.
Answer: ArrayList.get(index). Returns element at specified position without removing it.
Answer: while (iterator.hasNext()) { iterator.next(); }. Uses iterator methods to safely traverse elements.
Answer: Collections.sort(arrayList). Sorts elements using their natural comparison order.
Answer: ArrayList.addAll(collection). Appends all elements from source collection.
Answer: ArrayList.lastIndexOf(element). Returns highest index where element appears.
Answer: ArrayList.get(index). Returns element at specified position without removing it.
Answer: ArrayList.replaceAll(unaryOperator). Applies function to transform each element in place.
Answer: ArrayList.set(index, element). Updates element at specified index position.
Answer: break. Immediately exits loop when condition is met.
Answer: O(n). Requires shifting all subsequent elements leftward.
Answer: ArrayList.contains(element). Returns boolean indicating element presence in the list.
Answer:
Answer: To access each element in the ArrayList. Allows examination or processing of every element sequentially.
Answer: Iterator.hasNext(). Returns true if more elements remain to iterate.
Answer: O(1). Direct array access provides constant time retrieval.
Answer: O(1). Direct array access provides constant time retrieval.
Answer: ArrayList.add(element). Appends element to the end of the list.
Answer: Object or specified type. Returns the generic type or Object if unspecified.
Answer: ArrayList list = new ArrayList<>(capacity);. Pre-allocates memory for specified number of elements.
Answer: O(1). Appending to end requires no element shifting.
Answer: ArrayList.equals(object). Compares both content and order of elements.
Answer: O(1). Appending to end requires no element shifting.
Answer: IndexOutOfBoundsException. Runtime exception for accessing non-existent index positions.
Answer: Iterator.hasNext(). Returns true if more elements remain to iterate.
Answer: ArrayList.lastIndexOf(element). Returns highest index where element appears.
Answer: for (String s : arrayList) { System.out.println(s); }. Enhanced for loop prints each string element sequentially.
Answer: ArrayList.iterator(). Returns Iterator object for traversing the ArrayList.
Answer: ArrayList.isEmpty(). Returns boolean indicating if size equals zero.
Answer: ArrayList.remove(index). Removes element at specified position and returns it.
Answer: ConcurrentModificationException. Thrown when modifying ArrayList during iteration.
Answer: For-each loop. Enhanced for loop simplifies iteration without index management.
Answer: Object or specified type. Returns the generic type or Object if unspecified.
Answer: ArrayList.remove(element). Searches and removes first matching element found.
Answer: O(n). Must visit each element once for complete traversal.
Answer: ArrayList.remove(index). Removes element at specified position and returns it.
Answer: ArrayList.equals(object). Compares both content and order of elements.
Answer: ArrayList.set(index, element). Updates element at specified index position.
Answer: while (iterator.hasNext()) { iterator.next(); }. Uses iterator methods to safely traverse elements.
Answer: To simplify iteration over elements. Enhanced for loop provides cleaner, safer iteration.
Answer: ArrayList.contains(element). Returns boolean indicating element presence in the list.
Answer: To simplify iteration over elements. Enhanced for loop provides cleaner, safer iteration.
Answer: n−1. Last index equals size minus one due to zero-based indexing.
Answer: ArrayList list = new ArrayList<>(capacity);. Pre-allocates memory for specified number of elements.
Answer: ArrayList.toArray(). Converts ArrayList to standard array format.
Answer: O(n). Must visit each element once for complete traversal.
Answer: ArrayList.clear(). Removes all elements, making the ArrayList empty.
Answer: ArrayList.addAll(collection). Appends all elements from source collection.
Answer: ArrayList.retainAll(collection). Keeps only elements present in both collections.
Answer: ArrayList.add(index, element). Inserts element at specified position, shifting existing elements.
Answer: ArrayList.isEmpty(). Returns boolean indicating if size equals zero.