| |
| Introduction |
| An array is a collection of items.
Each slot in the array can hold an object or a primitive value.
Arrays in Java are objects that can be treated just like other objects in the language. |
| An array is an indexed table of like values. While they can
exist in more than one dimension, we are only interested in
one-dimensional arrays as depicted by the following: |
| |
|
| |
| |
| This array consists of five elements where each is an
integer value (217, 138, 92, 12, and 168). |
| |
| |
| To access a particular element within an array, its
corresponding index (offset) is used. For example, the
integer value at index location 3 within this array is 12.
Notice that the indexes are zero based because the offset
of the first element is always zero (you don't have to
skip over any other elements to get there). |
| |
| While all programming languages include the ability
to process arrays, Java provides enhanced integrity and
other features not found in other languages. |