Array

Jun 2, 2025

#

What is Array

An array is a linear data structure. It consists of linear ordered elements of the same data type, with the length of the data fixed after it is defined, thus allocated into continuous memory for storage. All elements can be accessed or assigned by index, starting from 0 and incrementing by 1 gradually.

array #

Example

In many programming languages, an array is a built-in data structure.

array = ['a', 'b', 'c']
array[0] # a
array[1] = 'd' # assign "d" to the second element
python

It's the easiest way to maintain the order relationship between data.

  • string

    string = ['H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd']
    python
  • matrix

    matrix = [
    [1, 2],
    [3, 4],
    ]
    python