August 2001
Beginner
482 pages
10h 52m
English
You access each of the array elements by referring to an offset from the array name followed by subscript within the braces. Array elements are counted from 0; therefore, the first array element is arrayName[0]. In the LongArray example, LongArray[0] is the first array element, LongArray[1] the second, and so forth.
This can be somewhat confusing. The array SomeArray[3] has three elements: SomeArray[0], SomeArray[1], and SomeArray[2]. More Generally, SomeArray[n] has n elements that are numbered SomeArray[0] through SomeArray[n-1].
Therefore, LongArray[25] is numbered from LongArray[0] through LongArray[24]. Listing 15.1 shows how to declare an array of five integers and fill each with a value.
Read now
Unlock full access