Answer:
- How many rows must be printed?
- 3
- How many cells in each row must be printed?
- 3 for row 0
- 2 for row 1
- 5 for row 3
Printing a 2D Array
Here is a program that creates a 2D array, then prints it out.
The way that the nested loops are written enable the program to print out the correct number of cells for each row. The expression uneven[row].length evaluates to a different integer for each row of the array.
| Row | Col | ||||
|---|---|---|---|---|---|
| 0 | 1 | 2 | 3 | 4 | |
| 0 | 1 | 9 | 4 | ||
| 1 | 0 | 2 | |||
| 2 | 0 | 1 | 2 | 3 | 4 |
QUESTION 14:
For the print method to work,
must every row of uneven be non-null?