Alternative Array Declaration Syntax

Alternative Array Declaration Syntax

XIX

There is a second form that may be used to declare an array:

type[ ] var-name;

Here, the square brackets follow the type specifier, and not the name of the array variable. For example, the following two declarations are equivalent:

The alternative declaration form is also useful when specifying an array as a return type for a method.

Report Page