• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 11. Arrays > Array Overview

Array Overview

Arrays are just another data type. Variables can contain strings, numbers, or other data types, including arrays. Just as you can do “string” types of things to variables containing strings and “number” types of things to variables containing numbers, when your variable’s value is an array, there is a unique set of “array” operations that you can execute. Strings and numbers are very familiar. Let’s take an overview of the way arrays work.

The idea with arrays is that any one variable can contain multiple values—each in a unique address within the variable. Compare a plain variable containing a number or string to a studio apartment or single-person home. Assuming that only one person lives in any given apartment at a time, it’s like a variable containing a string. You can replace the value in the variable or replace the person living in the apartment—but only one is in the variable or apartment at a time. If a regular variable is like a single apartment, an array is like an apartment building (see Figure 11.1). There might be 50 individual apartments in an entire building. Similarly, an array can have 50 individual locations for data (called indexes). Replacing the value in any one index is like replacing the resident in any one apartment.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint