---
title: "1D Array — AP Comp Sci A Definition & Exam Guide"
description: "A 1D array stores a fixed number of same-type elements in order, accessed by index. It's the backbone of AP CSA traversal, 2D arrays, and FRQ 3."
canonical: "https://fiveable.me/ap-comp-sci-a/key-terms/1d-array"
type: "key-term"
subject: "AP Computer Science A"
---

# 1D Array — AP Comp Sci A Definition & Exam Guide

## Definition

A 1D (one-dimensional) array in AP Computer Science A is a fixed-size data structure that stores elements of a single type in sequential order, where each element is accessed by an integer index starting at 0.

## What It Is

A 1D array is Java's most basic way to store a [list](/ap-comp-sci-a/key-terms/list "fv-autolink") of values. You declare it with a type and a size, like `int[] scores = new int[10];`, and Java gives you 10 slots in a row, each holding an `int`. Every slot is an **element**, and every element has an **index**. Indexes start at 0, so a 10-element [array](/ap-comp-sci-a/unit-4/array-creation-and-access/study-guide/umTe6NA38OqZOhMZjFWi "fv-autolink") runs from index 0 to index 9. That last part trips up more AP students than anything else in the course.

Two properties define a 1D array. First, the size is fixed. Once you create it, you can't add an 11th slot (that's what [ArrayList](/ap-comp-sci-a/unit-4/developing-algorithms-using-arraylists/study-guide/MKbteieYvLOpWIwfqiND "fv-autolink") is for). Second, every element is the same type. An `int[]` holds only ints, a `String[]` holds only String references. Think of it as a single row of numbered lockers, all the same shape, where the number on the locker (the index) is how you get to what's inside (the element).

## Why It Matters

1D arrays anchor the data-structures stretch of AP CSA. They're where you first learn [traversal](/ap-comp-sci-a/key-terms/traversal "fv-autolink"), the [pattern](/ap-comp-sci-a/unit-1/why-programming-why-java/study-guide/lVK6rmrBuug17i1Hna9z "fv-autolink") of visiting every element with a `for` loop or enhanced `for` loop, and that pattern repeats for the rest of the course. ArrayLists are basically resizable arrays with method calls instead of bracket notation. 2D arrays are literally arrays whose elements are 1D arrays. The classic algorithms the exam loves (find the max, sum the elements, count matches, shift or reverse elements, linear search) are all built on 1D array traversal. If you can't traverse a 1D array confidently, every later unit gets harder. If you can, 2D arrays become "do the 1D thing twice."

## Connections

### Index and Element (Unit 6)

These are the two vocabulary words that make arrays work. The [index](/ap-comp-sci-a/key-terms/index "fv-autolink") is the position number (starting at 0), and the element is the value stored there. Asking for `arr[arr.length]` is the classic mistake, because the last valid index is `length - 1`, and going past it throws an ArrayIndexOutOfBoundsException at runtime.

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

Traversal means visiting every element, usually with a standard `for` [loop](/ap-comp-sci-a/key-terms/loop "fv-autolink") (when you need the index) or an enhanced `for` loop (when you only need the values). Almost every array MCQ and FRQ is really a traversal question wearing a costume.

### 2D Arrays (Unit 8)

In Java, a 2D array is an array of 1D arrays. That's why the [outer loop](/ap-comp-sci-a/key-terms/outer-loop "fv-autolink") of a nested enhanced `for` loop over a `String[][]` iterates over `String[]` rows, not individual Strings. Once that clicks, 2D array code stops looking mysterious.

### ArrayList (Unit 7)

ArrayList is the flexible sibling of the 1D array. It grows and shrinks, but you trade bracket syntax for method calls like `get(i)` and `add(x)`. The exam loves making you translate logic between the two, so know both syntaxes cold.

### [Modulo Operator (%) (Unit 1)](/ap-comp-sci-a/key-terms/modulo-operator-percent)

The `%` operator pairs naturally with arrays for wrap-around logic. `index % arr.length` always lands inside the array's bounds, which is how circular traversals and "every nth element" problems work.

## On the AP Exam

Arrays show up everywhere on the AP CSA exam. In the multiple-choice section, expect questions that make you trace a loop over an array, spot off-by-one errors, predict an ArrayIndexOutOfBoundsException, or compare standard versus enhanced `for` loop behavior (remember, assigning to an enhanced `for` loop variable does not change the array). On the free-response section, FRQ 3 is dedicated to Array/ArrayList, so you will write code that creates, traverses, and modifies a 1D array or ArrayList. Your 1D array skills also get tested indirectly. Practice questions on 2D arrays constantly check whether you know that the outer loop of a nested enhanced `for` loop iterates over 1D arrays (the rows), which only makes sense if you understand that a 2D array is built from 1D arrays. Master find-the-max, sum, count, search, and shift on a 1D array and you've covered most of what FRQ 3 can throw at you.

## 1D array vs ArrayList

A 1D array has a fixed size set at creation and uses bracket syntax (`arr[i]`, `arr.length`). An ArrayList resizes automatically and uses methods (`list.get(i)`, `list.size()`, `list.add(x)`). Note the parentheses difference too. Arrays use `length` with no parentheses; ArrayLists use `size()` with them. Mixing those up is one of the most common syntax errors on FRQs.

## Key Takeaways

- A 1D array stores a fixed number of same-type elements in order, and you access each element with an integer index that starts at 0.
- The last valid index of an array is `arr.length - 1`, and accessing any index outside 0 through length minus 1 throws an ArrayIndexOutOfBoundsException.
- Use a standard for loop when you need the index or want to modify elements, and an enhanced for loop when you only need to read values.
- Changing the loop variable inside an enhanced for loop does not change the array itself, which is a favorite MCQ trap.
- A 2D array in Java is just an array of 1D arrays, so everything you learn about 1D traversal applies twice in nested loops.
- FRQ 3 on the AP exam targets Array/ArrayList, so practice writing traversal algorithms like sum, max, count, and search by hand.

## FAQs

### What is a 1D array in AP Computer Science A?

It's a fixed-size structure that stores elements of one type in sequential order, like `int[] nums = new int[5];`. Each element is accessed by an index from 0 to length minus 1.

### Can you change the size of a 1D array in Java?

No. Once created, an array's length is fixed forever. If you need a resizable list, use an ArrayList, which grows and shrinks with `add` and `remove` calls.

### What's the difference between a 1D array and an ArrayList?

Arrays are fixed-size and use brackets (`arr[i]`, `arr.length`), while ArrayLists resize automatically and use methods (`list.get(i)`, `list.size()`). The AP exam tests both syntaxes, especially on FRQ 3.

### Does array indexing start at 0 or 1 in Java?

0. A 10-element array has valid indexes 0 through 9, so `arr[10]` throws an ArrayIndexOutOfBoundsException. Off-by-one errors here are a top source of lost MCQ points.

### Is a 2D array just made of 1D arrays?

Yes. In Java a `String[][]` is an array whose elements are `String[]` arrays. That's why the outer loop of a nested enhanced for loop must use the 1D array type (like `String[] row`), not the element type.

## Structured Data

```json
{"@context":"https://schema.org","@graph":[{"@type":"LearningResource","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/1d-array#resource","name":"1D Array — AP Comp Sci A Definition & Exam Guide","url":"https://fiveable.me/ap-comp-sci-a/key-terms/1d-array","learningResourceType":"Concept explainer","educationalLevel":"AP® / High School","about":{"@id":"https://fiveable.me/ap-comp-sci-a/key-terms/1d-array#term"},"audience":{"@type":"EducationalAudience","educationalRole":"student"},"dateModified":"2026-06-12T22:52:43.404Z","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/1d-array#term","name":"1D array","description":"A 1D (one-dimensional) array in AP Computer Science A is a fixed-size data structure that stores elements of a single type in sequential order, where each element is accessed by an integer index starting at 0.","url":"https://fiveable.me/ap-comp-sci-a/key-terms/1d-array","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 1D array in AP Computer Science A?","acceptedAnswer":{"@type":"Answer","text":"It's a fixed-size structure that stores elements of one type in sequential order, like `int[] nums = new int[5];`. Each element is accessed by an index from 0 to length minus 1."}},{"@type":"Question","name":"Can you change the size of a 1D array in Java?","acceptedAnswer":{"@type":"Answer","text":"No. Once created, an array's length is fixed forever. If you need a resizable list, use an ArrayList, which grows and shrinks with `add` and `remove` calls."}},{"@type":"Question","name":"What's the difference between a 1D array and an ArrayList?","acceptedAnswer":{"@type":"Answer","text":"Arrays are fixed-size and use brackets (`arr[i]`, `arr.length`), while ArrayLists resize automatically and use methods (`list.get(i)`, `list.size()`). The AP exam tests both syntaxes, especially on FRQ 3."}},{"@type":"Question","name":"Does array indexing start at 0 or 1 in Java?","acceptedAnswer":{"@type":"Answer","text":"0. A 10-element array has valid indexes 0 through 9, so `arr[10]` throws an ArrayIndexOutOfBoundsException. Off-by-one errors here are a top source of lost MCQ points."}},{"@type":"Question","name":"Is a 2D array just made of 1D arrays?","acceptedAnswer":{"@type":"Answer","text":"Yes. In Java a `String[][]` is an array whose elements are `String[]` arrays. That's why the outer loop of a nested enhanced for loop must use the 1D array type (like `String[] row`), not the element type."}}]},{"@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":"1D array"}]}]}
```
