9.3 Aggregate Two-Dimensional Array Operations

As with single-dimensional arrays, Java does not support aggregate operations on multidimensional arrays. For example, we cannot print the contents of an array using only the array name. Instead, we need to process each element individually.

9.3.1 Processing All the Elements of a Two-Dimensional Array

To process all the elements of a two-dimensional array, we use nested for loops that access and process each element individually. Often, the most logical way to process all elements is in row order, and within each row, in column order. We could also process elements one column at a time if that is more logical for the problem at hand.

In our nested for loops, the outer for loop will process ...

Get Java Illuminated, 5th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.