Characteristics of arrays in Java
A list of characteristics follows in no particular order:
- All arrays in Java are one-dimensional arrays.
- (Multidimensional
arrays are created by creating tree structures of one-dimensional
arrays.)
- Each array in Java is encapsulated in a special type of object that I
will refer to as an array object.
- As with all objects, an array object must be accessed via a reference to
the array object.
- When the declared type of an array is one of the eight primitive types,
the actual values are stored in the array elements in the array object.
- When the declared type of an array is the type of an object (array
object or ordinary object),
- references to the objects are stored in
the array elements and the objects actually exist elsewhere in memory.
- As with instance variables, the elements in an array are typically
initialized with the standard default values for the types involved
(zero, false, or null). That is not the case in this program
however.
- The array that is encapsulated in an array object may have none, one, or
more elements. (Yes, it is possible for a Java array to have no
elements, but that normally occurs only in special circumstances.)