Mega Code Archive
0071 Allocate memory for array
You allocate memory using new and assign it to array variables. new is a special operator that allocates memory. The general form is:
arrayVar = new type[size];
type specifies the type of data being allocated.
size specifies the number of elements.
arrayVar is the array variable.
The following two statements first create an int type array variable and then allocate memory for it to store 12 int type values.
int days[];
days = new int[12];
days refers to an array of 12 integers.
All elements in the array is initialized to zero.