Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 13:26, 9 August 2025 by Dylan (talk | contribs) (new)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

An array is simply a collection of values. They are stored next to each other in memory so can be accessed directly using their memory address (plus an offset to get the value at a specific index).

Array data types

edit edit source

Arrays must contain values of only one data type.

For example, this array would be fine as it only contains integers:

[4, 9, 20, 50, 299]

However this array would not be, as it contains both strings and booleans:

["hello", "world", true, "Tokyo", false]

Some dynamically-typed programming languages, such as Python, allow you to have values of multiple data types in a single list. No statically typed programming language offers this.

Common array + collection methods

edit edit source

There are some common methods or fields you can access on arrays, lists and other collections in most programming languages. They may have different names to those listed below, but should be present.