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

Chapter 11. Manipulating Information > Ordering Information with Arrays

Ordering Information with Arrays

When you have many pieces of related information that you want to store, you may need to use the Array class to help arrange it. Arrays are containers that hold data, just as variables do, except that arrays hold data in a specific sequence. The position of each piece of data is called its index. Indexes are numbered sequentially, beginning at 0, so that each piece of data corresponds to an index, as in a two-column table (Figure 11.32). Because each piece of data is ordered numerically, you can retrieve and modify the information easily—and, most important, automatically—just by referencing its index. Suppose that you’re building an address book of a list of your important contacts. You can store names in an array so that index 0 holds your first contact, index 1 holds your second contact, and so on. By using a looping statement, you can quickly check every entry in the array automatically.

Figure 11.32. An array is like a two-column table with an Index column and a corresponding Value column.



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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