How can you use the length field with a two-dimensional array? Show an example two-dimensional array declaration and provide thelengthvalues for the example array.

What will be an ideal response?


A one dimensional array has a length field that holds the number of elements in the array. With a two-dimensional array, the length field holds the number of rows in the array. Each row, in turn, has a length field that holds the number of columns in the row. For example, suppose you declare a rents array as follows:?int[][] rents = { {400, 450, 510},   {500, 560, 630},   {625, 676, 740},   {1000, 1250, 1600} };?The value of rents.length is 4 because there are four rows in the array. The value of rents[0].length is 3 because there are three columns in the first row of the rents array. Similarly, the value of rents[1].length also is 3 because there are three columns in the second row.

Computer Science & Information Technology

You might also like to view...

There are two versions of the subscript operation: ____.

A. read and write B. move and write C. write and run D. read and run

Computer Science & Information Technology

When the items in two data structures are related by their indexes, it is said that a(n) ____________ exists between the data structures.

a. exclusive association b. logical connection c. parallel relationship d. binary link

Computer Science & Information Technology

In creating your own subclass Exceptions, you can override the ________ built-in function.

a. get Code() b. to String() c. get Previous() d. get File()

Computer Science & Information Technology

The second generation of programming languages came to be known as "high-level" languages because statements could be expressed more closely to the way people think than the way the computer "thinks."

Answer the following statement true (T) or false (F)

Computer Science & Information Technology