June 2004
Intermediate to advanced
848 pages
21h 28m
English
There is a quirk of syntax in that the array declaration bracket pairs can “float” to be next to the element type, to be next to the data name, or to be in a mixture of the two. The following are all valid array declarations:
int a [] ;int [] b = { 5, 2, 3 } ;char c [][] = new char[12][31];char[] d [] = { {1,1,1,1}, {2,2,2,2} }; // creates d[2][4]char[][] e;byte f [][][] = new byte [3][3][7];byte [][] g[] = new byte [3][3][7];short [] h, i[], j, k[][];
If array brackets appear next to the type, they are part of the type, and apply to every variable in that declaration. In the code above, “j” is an array of short, and “i” is an array of arrays of short. If the array brackets are next to the variable name, ...
Read now
Unlock full access