来自 JLS http://docs.oracle.com/javase/specs/jls/se5.0/html/arrays.html#10.2
以下是不创建数组的数组变量声明示例:
int[ ] ai; // array of int
short[ ][ ] as; // array of array of short
Object[ ] ao, // array of Object
otherAo; // array of Object
Collection<?>[ ] ca; // array of Collection of unknown type
short s, // scalar short
aas[ ][ ]; // array of array of short
以下是一些创建数组对象的数组变量声明示例:
Exception ae[ ] = new Exception[3];
Object aao[ ][ ] = new Exception[2][3];
int[ ] factorial = { 1, 1, 2, 6, 24, 120, 720, 5040 };
char ac[ ] = { 'n', 'o', 't', ' ', 'a', ' ',
'S', 't', 'r', 'i', 'n', 'g' };
String[ ] aas = { "array", "of", "String", };
[ ] 可以作为类型的一部分出现在声明的开头,或者作为特定变量的声明符的一部分,或者两者兼而有之,如下例所示:
byte[ ] rowvector, colvector, matrix[ ];
这个声明相当于:
byte rowvector[ ], colvector[ ], matrix[ ][ ];