What Are Arrays / Lists?

Arrays and lists are collections of variables stored inside one other variable. This allows us to store lists of related data together and access and modify them together. An array could consist of a list of names, locations, numbers, or a list of anything. A list is a data structure, as it takes up more than one memory location or address.

An array has both values and indexes, the values are the actual items we store in the list and the indexes refer to the location in the list. List indexes start at 0, so the first element in the list will be at index location 0, then the next will be at index 1. This often confuses new developers, list indexing starts at 0 not 1.

Some programming languages enforce strict list values and others allow dynamic variables types. For example, the Java programming language will only allow you to create lists of one type of variables, whereas the programming language JavaScript allows you to create a list of different variables types. A strict list of integers can only contain integers, a dynamic list could contain some integers, some characters, and some booleans.

Size is another aspect of a list that can be strict of dynamic. Some programming languages contain lists that have a strict size and other types of lists may be dynamic in size, meaning you can add and remove elements without restriction. A fixed length list’s size cannot be changed throughout a programs execution. What most people don’t realise, under the covers, there are only fixed size lists. When a dynamic list’s size is changed then a new fixed sized list is created and is swapped with your variable. However, when programming with dynamic lists you don’t see this, but if memory usage is a concern it may be something to keep in mind. The creation of new fixed size lists, the deletion and swapping of the old variable, can add additional processing to your programs execution. Although, this is hardly ever a concern in modern programming.

List Indexing


Getting the value at index 3 is the number 4.

Getting the value at index 0 is the number 0.


A String is a special type of variable, that most mistaken believe to be a primitive when in actual fact it is a list of character primitives. Making it a data structure. Strings can be thought of as text, they can contain any number of unicode characters (letters, numbers, special character). Some programming languages force you to put character values in single quotes, and strings inside double quotes. However, other programming languages are less strict and will let you put either in double/single quotes.

Strings are not initilised the same as lists, they do not appear the same as lists, which is why a lot of people mistaken take them for primitive variables. A String can be treated as a normal variable, but can also be treated as a list. By this I mean, you can still get values at certain indexes of strings, that will return the character at that index. But, as shown below, they appear similar to primitives when written in code.

Character vs. Strings

Leave a Reply