Java Reference
In-Depth Information
Alternative Array Declaration Syntax
There is a second form that can be used to declare an array:
type [ ] var-name ;
Here, the square brackets follow the type specifier, not the name of the array variable. For
example, the following two declarations are equivalent:
The following declarations are also equivalent:
This alternative declaration form offers convenience when declaring several arrays at the
same time. For example,
This creates three array variables of type int . It is the same as writing
The alternative declaration form is also useful when specifying an array as a return type for
a method. For example,
Search WWH ::




Custom Search