What is an array?
An array is a container object that can hold multiple values of a single type. The length of the array is set when the array is created. An array can hold primitive types as well as references of the object. Since arrays are treated as objects in Java, they are created at runtime, the length of the array is fixed.
Features of an array in Java
- Arrays are dynamically allocated on the heap.
- Arrays are created at runtime.
- The array length is fixed.
- Direct superclass of an array is Object class.
- Arrays can hold reference variables of other objects.
Types of array
There are two types of arrays in java –