Search⌘ K
AI Features

Arrays

Explore Kotlin arrays to understand their fixed-length sequential storage and how they differ from lists and sets. Learn to create arrays using arrayOf and manipulate elements by accessing indexes.

Like lists and sets, arrays store multiple values in a linear data structure.

What is an Array?

An array is a basic data structure in all programming languages. It stores multiple elements by placing them consecutively in memory. This structure is represented in the following illustration:

Array data structure. Elements are stored contiguously in memory and index starts at zero. [Source: https://beginnersbook.com/2018/10/data-structure-array/]
Array data structure. Elements are stored contiguously in memory and index starts at zero. [Source: https://beginnersbook.com/2018/10/data-structure-array/]

What’s the Difference Between Arrays, Lists, and Sets?

...