2.7.Declaring a Variable to Refer to an Array
The above program declares anArra with the following line of code:
int anArray; // declares an array of integers
Like declarations for variables of other types, an array declaration has two components: the array’s type and the array’s name. An array’s type is written as type [ ], where type is the data type of the contained elements; the square brackets are special symbols indicating that this variable holds an array. The size of the array is not part of its type (which is why the brackets are empty). An array’s name can be anything you want, provided that it follows the rules and conventions as previously discussed in the naming section. As with variables of other types, the declaration does not actually create an array — it simply tells the compiler that this variable will hold an array of the specified type.
Similarly, you can declare arrays of other types:
You can also place the square brackets after the array’s name:
float anArrayOfFloats; // this form is discouraged
However, convention discourages this form; the brackets identify the array type and should appear with the type designation.