The different ways to declare an array in Java

 

The following from:

 https://docs.oracle.com/javase/specs/jls/se7/html/jls-10.html

The [] may appear as part of the type at the beginning of the declaration, or as part of the declarator for a particular variable, or both.

For example:

byte[] rowvector, colvector, matrix[];

This declaration is equivalent to:

byte rowvector[], colvector[], matrix[][];

Leave a Reply