Lists hold an ordered collection of objects. Lists in Apex are synonymous with arrays and the two can be used interchangeably.

The following two declarations are equivalent. The colors variable is declared using the List syntax.

`List<String> colors = new List<String>();`

Alternatively, the colors variable can be declared as an array but assigned to a list rather than an array.

`String[] colors = new List<String>();`

Generally, it’s easier to create a list rather than an array because lists don’t require you to determine ahead of time how many elements you need to allocate.

You can add elements to a list when creating the list, or after creating the list by calling the add() method. This first example shows you both ways of adding elements to a list.

`// Create a list and add elements to it in one step
List<String> colors = new List<String> { **'red'**, **'green'**, **'blue'** };
// Add elements to a list after it has been created
List<String> moreColors = new List<String>();
moreColors.**add**(**'orange'**);
moreColors.**add**(**'purple'**);`

List elements can be read by specifying an index between square brackets, just like with array elements. Also, you can use the get() method to read a list element. This example is based on the lists created in the previous example and shows how to read list elements using either method. The example also shows how to iterate over array elements.