Array Creation and Access

Sophie Anderson
4 min read
Listen to this study note
Study Guide Overview
This study guide covers arrays in Java, including: array declaration and initialization (using constructors and pre-initialized values), accessing elements using zero-based indexing, determining array length with arrayName.length
, and understanding ArrayIndexOutOfBoundsException
. It also explains how different data types are initialized within arrays.
#Introduction to Arrays
Arrays are used to store one type of data, whether it is a primitive or reference data type. Arrays themselves are reference types. They are best thought of as a list of items with a fixed size, as arrays have a set size that cannot be changed (don’t confuse this with ArrayLists which can also be thought of as a list - we'll learn about ArrayLists in Unit 6).
Arrays are denoted by braces ({}), with items separated by commas such as the following:
{true, true, false, true}
Before we can use arrays, we need to have an import statement, which is
import java.util.Arrays;
#Making Arrays
There are t...

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