If you draw out a grid with m rows and n columns, how many individual cells are in the grid? This is euqivalent to the number of elements in an m-by-n array. Note that you can't write this as a single numerical value, or even as a single variable. But you CAN calculate it with the variables given. What mathematical operation would you use?

I should note that Java does not enforce the idea of rows and columns in a 2D array. It is often easier for us to think of them that way, but

you should remember that this is only a trick in thinking about how arrays work. For example, if we declare an array as:

You can think of this as an array with 10 rows and 20 columns or as an array with 20 columns and 10 rows. The first interpretation is probably the most natural since it mimics matrix notation from linear algebra (if you are familiar with that field in mathematics), but the second interpretation may be more natural, depending on how the array will be used. In either case, the number of elements is the same. (How many elements does this example array have?)

Layne

[ May 22, 2005: Message edited by: Layne Lund ]