In Java arrays have a fixed length that is specified during initialization, and determines the number of its elements. Once we set the length of the array is not possible to change it.
Declaring an array
Arrays in Java declare as follows:
int[] myArray;
Here the variable myArray is the name of the array, which is of type (int []) ie We declare an array of integers. With [] indicates that the variable that will declare an array rather than a single element.
In return the name of the variable which is of type array is a reference (reference), which points to null, as it is not yet memory allocated for the array elements.
Here is how a variable of type array that is declared, but has not allocate memory for array elements:
Creation (allocation) array – operator new
In Java, an array is created with the keyword new, which serves to allocate (allocating) memory:
int[] myArray = new int[6];
In the example, allocate an array of size 6 elements of an integer. this means that dynamic memory (heap) dedicates a section of 6-then consecutive integers. Elements of arrays are always stored in dynamic memory (in the so-called heap).
To allocate array in brackets set the number of its elements (nonnegative integer) and so its length is fixed. The type of elements to write after new, to indicate which type elements must allocate memory. Array already set length may change i.e. Arrays are fixed length.