Two Dimensional Arrays
This chapter expands our discussion on one-dimensional arrays to two dimensional arrays. A two dimensional array is a data structure that contains a collection of cells laid out in a two dimensional grid, similar to a table with rows and columns although the values are still stored linearly in memory. Each cell in a two dimensional array can be accessed through two indexes that specify the row number and column number respectively. Like s one dimensional array, the range of each index is from zero to the size of the row or column minus one. A nested for loop is commonly used to initialize, manipulate, and access the values in a two dimensional array.
15. Null Rows
Answer:
Yes. If a row does not exists (and therefore
uneven[row]
isnull
) the following code will throw anException
:for ( int col=0; col < uneven[row].length; col++ )
Null Rows
length
is used:
|
However, the code does assume that
uneven
is non-null
.Question 15:
(Thought Question: ) Are 3-dimensional arrays possible?