12.3. Multi-dimensional arrays: jagged arrays

Unlike rectangular arrays, jagged arrays are arrays of arrays. [6] In the case of rectangular arrays, we can think of a 2D array as a planar rectangular table, where the first-level array specifies a row, and the second-level array specifies a cell in the row. Notice that the number of cells in each row has to be the same. If row 0 has 10 cells, row 1 will have 10 cells – a rectangular array is always a neat rectangle (hence the name).

[6] Since Java doesn't differentiate between rectangular and jagged arrays, you may have heard your Java instructor telling you that multi-dimensional arrays in Java are arrays of arrays too. But, as you shall see, there's a difference between jagged and rectangular ...

Get From Java to C#: A Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.