Array

Ethan Taylor
9 min read
Listen to this study note
Study Guide Overview
This unit covers arrays, a data structure for storing multiple pieces of data of a single type. Key concepts include array creation and initialization, accessing elements using indices, traversing arrays (using standard and enhanced for loops), and common array algorithms (finding min/max, computing sum/average, checking criteria, shifting/rotating elements, and reversing elements). This unit represents 10-15% of the AP exam.
#Unit 6 Overview: Array
#The Big Takeaway of this Unit
#Exam Weighting
- 10-15% of the test
- Roughly 4 to 6 multiple-choice questions
- A possible topic of FRQ #3, which may test your ability to make arrays and algorithms.
#Enduring Understanding
In this unit, we will start learning about data structures, which are structures that store multiple pieces of data. You will learn about three of them in this course: 1-D Arrays in this unit, ArrayLists in Unit 7, and 2-D Arrays in Unit 8. Arrays store only one type of data, whether that be a primitive data type or a reference data type, and they are of fixed size. When used for loops, we can perform many functions with arrays and build algorithms with them, as well.
#Building Computational Thinking
In this unit, you will learn three things that are important for larger programs: how to create an array, how to traverse (going through all the elements) an array, and how to manipulate the elements in an array. One of the common mistakes that you may make at first is an ArrayIndexOutOfBoundsException, which occurs when you try to access an element where none exists, but with some practice, you will be flawless with arrays!
#Main Ideas for this Unit
- Initializing Arrays
- Accessing Elements in Arrays
- Traversing Arrays
- Array Algorithms
#6.1 Array Creation and Access
An array is a container object that holds a fixed number of values of a single type. The length of an array is established when the array is created. After creation, its length is fixed.
Arrays are used to store a list of items, such as items in a shopping cart, a list of student names in a classroom, or a list of numbers representing student scores on a test. To declare an array in Java, you can use the following syntax:
java
type[] arrayName;
Here, [type] is the type of element that the array will store (such as [int], [double], [String], etc.) and [arrayName] is the name of the array. Arrays can store primitive types and objects.
For example, to create an array of integers with the name [scores], you would write:
java...

How are we doing?
Give us your feedback and let us know how we can improve