Introduction to Arrays
Summary and Introduction to Arrays
An array is a data structure that is used collect multiple variables of the same data type together into one variable. Rather than having separate variable names for many different integers, for instance, you could collect all of them together into one variable. This does not mean that you will want to have all of the integers in any program united into one integer array. However, there will often be times when certain integer variables are all related to one another in a way appropriate for an array.
The key thing to understand about arrays is that the data is collected together so that any element in the array can be accessed from the array using an index. Basically, you can think of an array as a list of elements where each of the elements has a unique place in the list, such as 1st, 2nd, or 25th. You can access any element from the list using its location in the list. Arrays can also be used as unordered sets, which are lists where the order is unimportant.