Usual View of a 2D Array

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page

Answer:

Yes.

Usual View of a 2D Array

RowCol
01234
0 1 9 4

1 0 2

2 0 1 2 3 4
uneven

Usually you think of a 2D array as a table, not the complicated structure of the previous page. For example,

int[][] uneven = 
    { { 1, 9, 4 },
      { 0, 2},
      { 0, 1, 2, 3, 4 } };

is usually thought of as like the table on the right. Only occasionally do you have to think of "arrays of references to 1D arrays."

Now consider how you would print out every element contained in array uneven.

QUESTION 13:

  • How many rows must be printed?
  • How many cells in each row must be printed?