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

  1. Arrays are dynamically allocated on the heap.
  2. Arrays are created at runtime.
  3. The array length is fixed.
  4. Direct superclass of an array is Object class.
  5. Arrays can hold reference variables of other objects.

Types of array

There are two types of arrays in java – 

  1. Single dimensional array
  2. Multi-dimensional array