In java arrays are objects.
Java wrap these bare-bone arrays within an object hence
All methods of an Object can be invoked on an array.
**int a[]** = new int[5];
5
inside the square bracket says that you are going to store five values and is the size of the array ‘n’.
- Declaration: The code set in bold are all variable declarations that associate a variable name with an object type.
Instantiation: The new keyword is a Java operator that creates the object.
and since in java arrays are objects, it is necessary.
Initialization: The new operator is followed by a call to a constructor, which initializes the new object.
NB.
In java,Memory is constantly being allocated dynamically(objects are allocated memory dynamically by new operator) and then "forgotten" (the language actually forces you to forget about them). That is, the coder leaves it to the garbage collection engine to clean up his memory allocation mess.
In C, concept of static memory allocation allow declaration of
int a[10];