<<< Two-dimensional arrays and the instance variable length | Index | Nested for loops >>> |
Code that creates a 3x2 array and initializes it in one statement
int[][] numbers = { { 1, 2 }, { 3, 4 }, { 5, 6 } };
To initialize a two-dimensional array when it is declared:
The elements of each row are enclosed within braces and separated by commas
All rows are enclosed within braces
Initialization of irregularly-shaped arrays is also permitted:
int[][] numbers = { { 1, 2, 5 }, { 3 }, { 5, 6, 8, 2, 4 } };
<<< Two-dimensional arrays and the instance variable length | Index | Nested for loops >>> |