---
title: "List — AP Computer Science A Definition & ArrayList Guide"
description: "A list is an ordered collection where every element has an index. In AP CSA you use it through ArrayList, with add, get, set, remove, and size methods."
canonical: "https://fiveable.me/ap-comp-sci-a/key-terms/list"
type: "key-term"
subject: "AP Computer Science A"
---

# List — AP Computer Science A Definition & ArrayList Guide

## Definition

In AP Computer Science A, a list is an ordered collection of elements where each element sits at a unique index starting from 0. You work with lists through Java's ArrayList class, which can grow and shrink as you add and remove elements, unlike a fixed-length array.

## What It Is

A list is an ordered collection of elements where every element has its own position, called an [index](/ap-comp-sci-a/key-terms/index "fv-autolink"). Order matters. The element at index 0 stays at index 0 until something explicitly moves it, so a list is basically a numbered lineup of data.

In AP CSA, "list" almost always means **[ArrayList](/ap-comp-sci-a/unit-4/developing-algorithms-using-arraylists/study-guide/MKbteieYvLOpWIwfqiND "fv-autolink")**, Java's resizable list [class](/ap-comp-sci-a/unit-3/abstraction-and-program-design/study-guide/o9VgVeIpKRYZ7N7rXfUz "fv-autolink"). You declare one like `ArrayList<Integer> nums = new ArrayList<Integer>();` and manage it with a small set of methods: `add(element)` to append, `add(index, element)` to insert, `get(index)` to read, `set(index, element)` to replace, `remove(index)` to delete, and `size()` to count elements. Two things trip people up. First, indices run from 0 to `size() - 1`, so `get(list.size())` throws an IndexOutOfBoundsException. Second, when you `add` or `remove` in the middle, every element after that spot shifts, and their indices change. That shifting behavior is the source of half the ArrayList bugs you'll ever write.

## Why It Matters

Lists live in the [data collections](/ap-comp-sci-a/unit-4 "fv-autolink") portion of the course, the same stretch that covers arrays, traversals, and searching and sorting algorithms. Nearly every [algorithm](/ap-comp-sci-a/key-terms/algorithm "fv-autolink") question in that part of the course assumes you can store data in an ArrayList, walk through it with a loop, and read or change elements by index. Lists are also where the exam tests dynamic behavior. Arrays have a fixed length, so any question about a collection that grows as a program runs (adding reviews, enrolling students, collecting scores) is really a list question. If you can't traverse an ArrayList confidently, including removing elements without skipping any, the free-response section gets very hard very fast.

## Connections

### Array (Unit 4)

An [array](/ap-comp-sci-a/unit-4/array-creation-and-access/study-guide/umTe6NA38OqZOhMZjFWi "fv-autolink") is a list's fixed-size cousin. Both store elements in indexed order, but an array's length is locked at creation while an ArrayList resizes itself. Even the syntax splits: arrays use `arr[i]` and `arr.length`, lists use `list.get(i)` and `list.size()`.

### [Index (Unit 4)](/ap-comp-sci-a/key-terms/index)

The index is what makes a list a list instead of just a pile of values. Every element has a position from 0 to size minus 1, and that numbering is how every other list operation, from `get` to [linear search](/ap-comp-sci-a/key-terms/linear-search "fv-autolink"), finds anything.

### [Traversal (Unit 4)](/ap-comp-sci-a/key-terms/traversal)

A [traversal](/ap-comp-sci-a/key-terms/traversal "fv-autolink") visits every element of a list, usually with a for loop running from 0 to `size() - 1` or an enhanced for loop. Almost every list FRQ is secretly a traversal FRQ, since you have to loop through the list to count, sum, find, or modify elements.

### [Linear Search Algorithm (Unit 4)](/ap-comp-sci-a/key-terms/linear-search-algorithm)

Linear search is the go-to way to find a value in a list. It checks elements one index at a time from the front, which means it runs in O(n) time. Searching [4, 8, 15, 16, 23, 42] for 23 takes 5 comparisons because 23 sits at index 4.

## On the AP Exam

Multiple-choice questions hand you a snippet of ArrayList code and ask what it prints, how many comparisons a search makes, or which line throws an IndexOutOfBoundsException. Algorithm questions lean on lists too, like asking the time complexity of a linear search through an ArrayList (it's O(n)) or which data structure suits a sequential search. On the free response, one question is traditionally devoted to ArrayList. The 2022 FRQ Q3, for example, stored Review objects in an ArrayList and asked you to traverse it, pull data out with `get`, and build a new list from the results. You need to write traversals from scratch, use `add`, `get`, `set`, `remove`, and `size` correctly, and handle the classic trap of removing elements during a loop without skipping the element that shifts into the removed slot.

## List vs Array

Both are ordered, indexed collections, but an array has a fixed length set at creation while a list (ArrayList) grows and shrinks dynamically. The syntax is completely different too. Arrays use bracket notation like `arr[2] = 5` and the `length` field; ArrayLists use method calls like `list.set(2, 5)` and `size()`. Mixing these up, like writing `list[2]` or `arr.get(2)`, is a guaranteed lost point on the FRQ.

## Key Takeaways

- A list is an ordered collection where each element has a unique index, and in AP CSA you use it through Java's ArrayList class.
- List indices run from 0 to size() - 1, and accessing anything outside that range throws an IndexOutOfBoundsException.
- The core ArrayList methods are add, get, set, remove, and size, and they replace the bracket notation you use with arrays.
- Adding or removing an element in the middle of a list shifts every element after it, which changes their indices.
- When you remove elements while traversing a list, you have to adjust your loop index or you'll skip the element that slides into the removed spot.
- A linear search through a list checks one element per comparison from index 0, so it runs in O(n) time.

## FAQs

### What is a list in AP Computer Science A?

A list is an ordered collection of elements where each element has a unique index starting at 0. On the AP CSA exam you work with lists through Java's ArrayList class, using methods like add, get, set, remove, and size.

### Is a list the same as an array in Java?

No. Both are ordered and indexed, but an array's length is fixed when you create it while an ArrayList resizes automatically as you add or remove elements. They also use different syntax, with brackets and `length` for arrays versus method calls and `size()` for ArrayLists.

### Do ArrayList indices start at 0 or 1?

They start at 0, just like arrays and strings in Java. The last valid index is size() - 1, so calling get(list.size()) crashes with an IndexOutOfBoundsException.

### Can an ArrayList hold ints like int or double?

Not directly. ArrayLists only hold objects, so you use the wrapper classes Integer and Double, as in ArrayList<Integer>. Java autoboxing converts between int and Integer for you, so the code mostly looks the same once the list is declared.

### How is a list tested on the AP CSA exam?

Multiple-choice questions trace ArrayList code or count comparisons in a search, like finding that locating 23 in [4, 8, 15, 16, 23, 42] takes 5 comparisons. The free-response section traditionally includes an ArrayList question, such as 2022 FRQ Q3, where you traverse a list of objects and build or modify lists with add, get, and remove.

## Structured Data

```json
{"@context":"https://schema.org","@graph":[{"@type":"LearningResource","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/list#resource","name":"List — AP Computer Science A Definition & ArrayList Guide","url":"https://fiveable.me/ap-comp-sci-a/key-terms/list","learningResourceType":"Concept explainer","educationalLevel":"AP® / High School","about":{"@id":"https://fiveable.me/ap-comp-sci-a/key-terms/list#term"},"audience":{"@type":"EducationalAudience","educationalRole":"student"},"dateModified":"2026-06-12T23:22:05.137Z","isPartOf":{"@type":"Collection","name":"AP Computer Science A Key Terms","url":"https://fiveable.me/ap-comp-sci-a/key-terms"},"publisher":{"@type":"Organization","name":"Fiveable","url":"https://fiveable.me"}},{"@type":"DefinedTerm","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/list#term","name":"List","description":"In AP Computer Science A, a list is an ordered collection of elements where each element sits at a unique index starting from 0. You work with lists through Java's ArrayList class, which can grow and shrink as you add and remove elements, unlike a fixed-length array.","url":"https://fiveable.me/ap-comp-sci-a/key-terms/list","inDefinedTermSet":{"@type":"DefinedTermSet","name":"AP Computer Science A Key Terms","url":"https://fiveable.me/ap-comp-sci-a/key-terms"}},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is a list in AP Computer Science A?","acceptedAnswer":{"@type":"Answer","text":"A list is an ordered collection of elements where each element has a unique index starting at 0. On the AP CSA exam you work with lists through Java's ArrayList class, using methods like add, get, set, remove, and size."}},{"@type":"Question","name":"Is a list the same as an array in Java?","acceptedAnswer":{"@type":"Answer","text":"No. Both are ordered and indexed, but an array's length is fixed when you create it while an ArrayList resizes automatically as you add or remove elements. They also use different syntax, with brackets and `length` for arrays versus method calls and `size()` for ArrayLists."}},{"@type":"Question","name":"Do ArrayList indices start at 0 or 1?","acceptedAnswer":{"@type":"Answer","text":"They start at 0, just like arrays and strings in Java. The last valid index is size() - 1, so calling get(list.size()) crashes with an IndexOutOfBoundsException."}},{"@type":"Question","name":"Can an ArrayList hold ints like int or double?","acceptedAnswer":{"@type":"Answer","text":"Not directly. ArrayLists only hold objects, so you use the wrapper classes Integer and Double, as in ArrayList<Integer>. Java autoboxing converts between int and Integer for you, so the code mostly looks the same once the list is declared."}},{"@type":"Question","name":"How is a list tested on the AP CSA exam?","acceptedAnswer":{"@type":"Answer","text":"Multiple-choice questions trace ArrayList code or count comparisons in a search, like finding that locating 23 in [4, 8, 15, 16, 23, 42] takes 5 comparisons. The free-response section traditionally includes an ArrayList question, such as 2022 FRQ Q3, where you traverse a list of objects and build or modify lists with add, get, and remove."}}]},{"@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"AP Computer Science A","item":"https://fiveable.me/ap-comp-sci-a"},{"@type":"ListItem","position":2,"name":"Key Terms","item":"https://fiveable.me/ap-comp-sci-a/key-terms"},{"@type":"ListItem","position":3,"name":"List"}]}]}
```
