// (from the Carter book)
// Example 2:
//
// 1. Suppose we want to create a table with 3 rows and 4 columns.
// We can do this using the following statement (below):
public class MDArrayExample2
{
public static void main (String[] args)
{
int[] [] scores = {{5, 2, 7, 3},
{6, 8, 7, 9},
{4, 5, 2, 3}};
} // main method
} // MDArrayExample2 class
//
// Example 2: (continued):
//
// 2. On the right side of the assignment statement, the elements of each
// row of the array are enclosed by brace brackets and separated by commas.
// Similarly, the sets of values for each row are themselves enclosed by brace
// brackets and separated by commas. The statement could have been written all
// on one line, but we wrote it the way that we did to make the structure of
// the array clearer to the human reader.
// 3. The one-dimensional arrays that compose a 2-dimensional array need not
// all be of the same length, as the next example (3) illustrates.
No comments:
Post a Comment