11.4. Jagged Arrays

The multidimensional arrays that we have discussed are purely rectangular, meaning that all rows and columns have a uniform length. In jagged arrays, the array elements are themselves arrays of various dimensions and sizes (see Figure 11.1). A jagged array is also defined as an “array of arrays.”

Figure 11.1. A Jagged Array

Let's look at initialization of jagged arrays in C# and Java. There is no difference in the syntax of initializing jagged arrays in the two languages. A jagged array can be declared as an array of arrays, with each row having a different number of elements.

The following code snippet shows array declaration ...

Get .NET for Java Developers: Migrating to C# 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.