After declaring an array variable, memory is allocated to it. The "new" operator is used for the allocation of memory to the array object. The correct way to use the "new" operator is
names = new String;
Here, the new operator is followed by the type of variable and the number of elements to be allocated. In this example  operator has been used to place the number of elements to be allocated.
Lets see a simple example of an array,
In this example, a variable
'x' is declared which
has a type array of
int, that is,
int. The variable
is initialized to reference a newly created array object. The expression 'int
= new int' specifies that the array should have
To know the length of the Array, we use field
length, as shown.
Output for the given program:
Recommend the tutorial