Arrays: An Introduction

Learn about the structure, indexing, declaration, accessing, and components of an array in Java in this lesson.

Structure of an array

As we learned earlier, an array is a container object or a type of variable that holds a fixed number of values. These values should be of the same type. We should also mention the length when creating an array. When the array is created, that length is established. A variable can also be a container that holds one value of a single type. An array is a container that holds many values. So, an array is just another kind of variable.

Let’s try to have an image of an array in our minds. A variable is a box; an array is a box with many compartments. Inside each compartment, we keep one value. The capacity of our container has been increased drastically.

The following figure shows you how values can be stored inside an array container object:

Get hands-on with 1200+ tech skills courses.