An array is a group of items which have similar nature.

Arrays play a significant role in any programming language, as they allow the programmer to store more than one value in a variable. That is, you can use the same variable name to refer to all the values. An array is analogus to a shelf with many identical compartments. To identify a compartment, you just need to specify its position. Similarly, in a array variable, you can store many values of a single datatype. For example: 10 integers, 4 floating numbers, 12 characters etc. Not surprisingly, an array variable takes larger memory than a single variable of a datatype.

We can use the same name to access the values, but how do we differentiate between them. To do this we use an index into the array. For example, take an array(myArray) of 100 integers, we can access the hundredth unit:

myArray[99] = 3;

Notice something unusual? The index is usually zero based. So, the hundredth element is shown accessed using [99]. In other words, the index to the first item is at [0] and the index to the last item is [#elements -1].


  1. To learn how to use arrays for storing large amount of data.
  2. To learn how to use array to create a common reference for a large number of variables.