June 2004
Intermediate to advanced
992 pages
37h 55m
English
For further discussion of the correspondence between loops and arrays, see Relationship Between Data Types and Control Structures.
Loops and arrays are often related. In many instances, a loop is created to perform an array manipulation, and loop counters correspond one-to-one with array indexes. For example, these Java for loop indexes correspond to the array indexes:
Example 16-34. Java Example of an Array Multiplication
for ( int row = 0; row < maxRows; row++ ) {
for ( int column = 0; column < maxCols; column++ ) {
product[ row ][ column ] = a[ row ][ column ] * b[ row ][ column ];
}
}In Java, a loop is necessary for this array operation. But it's worth noting that looping structures and arrays ...
Read now
Unlock full access