Witscale Test Center

7.4 Arrays


7.4 Arrays

An array object represents a fixed-sized ordered grouping of data elements of the same type. It can hold primitive values or object references as its data elements. These data elements are accessible by the index.  An array is a homogeneous collection, we means it can hold only similar kind-of objects. For instance, an array of int values cannot hold strings objects. The array itself is always an object; it does not matter whether it is going to hold primitive elements or references to objects.

 

An array is the only built in collection in the Java language.  This built-in Java array is declared and created differently from most of the other Java objects. It is a subclass of java.lang.Object, it implements both the Serializable, and Cloneable interfaces. However, you cannot find a class definition for it in any of the Java platform classes. Its definition is built in the Java language, hence you will not find any .java source file for it either. There is another object representation of array in java.lang.reflect package. That Array is different from the built-in array we are discussing here.