February 2014
Beginner
1248 pages
62h 25m
English
Like one-dimensional arrays, multidimensional arrays can be initialized with array initializers in declarations. A two-dimensional array b with two rows and two columns could be declared and initialized with nested array initializers as follows:
int[][] b = {{1, 2}, {3, 4}};
The initial values are grouped by row in braces. So 1 and 2 initialize b[0][0] and b[0][1], respectively, and 3 and 4 initialize b[1][0] and b[1][1], respectively. The compiler counts the number of nested array initializers (represented by sets of braces within the outer braces) to determine the number of rows in array b. The compiler counts the initializer values in the nested array initializer for a row to ...
Read now
Unlock full access