go to previous page   go to home page   go to next page

Answer:

Yes. If a row does not exists (and therefore uneven[row] is null) the following code will throw an Exception:

for ( int col=0; col < uneven[row].length; col++ )

Null Rows

Here is a somewhat improved version of the program that tests each row to see if it exists. If the row exists, its length is used:


    // print out the array
    for ( int row=0; row < uneven.length; row++ )
    {
      System.out.print("Row " + row + ": ");
      if ( uneven[row] == null )
        System.out.print( "empty" );
      else
      {
        for ( int col=0; col < uneven[row].length; col++ )
          System.out.print( uneven[row][col] + " ");
      }
      
      System.out.println();
    }


However, the code does assume that uneven is non-null.


QUESTION 15:

(Thought Question: ) Are 3-dimensional arrays possible?


go to previous page   go to home page   go to next page