What Are Arrays?

In this lesson, an introduction to Arrays data structure is provided.

Definition

An array is a collection of similar data types in a sequenced format. The position of each data member in this sequence is represented with a number known as its index.

Elements of an Array

The members of this data collection are referred to as array elements.

Length of an Array

The total number of elements in an array is called the length of an array. This length is set once at the time of creation of an array and can’t be changed later in a program. We can check the length of an array using an inbuilt functionality of Java as arrayName.length.

Indexing

The indexes in an array always range from zero to length-1. For example, an array containing the first 100 natural numbers will have a length of 100 and indexes from 0 to 99.

Get hands-on with 1400+ tech skills courses.