Java Arrays Tutorial: Declare, Create, Initialize [Example]

What is an Array?

An array is a very common type of data structure wherein all elements must be of the same data type. Once defined, the size of an array is fixed and cannot increase to accommodate more elements.The first element of an array starts with index zero.

In simple words, it’s a programming construct which helps to replace this

Array Variables

Using an array in your program is a 3 step process –

1) Declaring your Array

2) Constructing your Array3) Initialize your Array

1) Declaring your Array


When you allocate memory for a multidimensional array, you need only specify the memory for the first (leftmost) dimension.

You can allocate the remaining dimensions separately.

In Java, array length of each array in a multidimensional array is under your control.