
Java Arrays and ArrayLists
IntermediateArrays and ArrayLists are the fundamental data structures for storing collections of elements in Java. An array is a fixed-size, ordered collection of elements of the same type, declared with bracket notation (int[] arr = new int[5]) and accessed by zero-based index. Arrays support efficient random access but cannot be resized after creation.
ArrayLists are part of the java.util package and provide a resizable alternative to arrays. They store objects (not primitives), support dynamic sizing with methods like add(), remove(), get(), set(), and size(), and handle autoboxing for primitive wrapper types. Understanding when to use arrays versus ArrayLists is a key design decision in Java programming.
This topic also covers array traversal using standard for loops and enhanced for-each loops, common algorithms (searching, finding min/max, summing, reversing), 2D arrays for tabular data, and the important distinction between passing arrays by reference versus passing primitives by value. These concepts form the foundation of AP Computer Science A Units 6 and 7, comprising 10-15% of the AP exam.
Practice a little. See where you stand.
Quiz
Reveal what you know — and what needs work
Adaptive Learn
Responds to how you reason, with real-time hints
Flashcards
Build recall through spaced, active review
Cheat Sheet
The essentials at a glance — exam-ready
Glossary
Master the vocabulary that unlocks understanding
Learning Roadmap
A structured path from foundations to mastery
Book
Deep-dive guide with worked examples
Lab
Hands-on practice for this subject
Key Concepts
One concept at a time.
Explore your way
Choose a different way to engage with this topic — no grading, just richer thinking.
Explore your way — choose one:
Curriculum alignment— Standards-aligned
Grade level
Learning objectives
- •Declare, initialize, and access elements in one-dimensional arrays using zero-based indexing
- •Traverse arrays using standard for loops and enhanced for-each loops to implement common algorithms
- •Create and manipulate ArrayLists using add, get, set, remove, and size methods
- •Explain autoboxing and unboxing between primitive types and wrapper classes
- •Declare and traverse 2D arrays using nested loops for row-by-row and column-by-column access
Recommended Resources
This page contains affiliate links. We may earn a commission at no extra cost to you.
Books
Barron's AP Computer Science A
by Roselyn Teukolsky
Head First Java
by Kathy Sierra and Bert Bates