logo
Учебник_ПОА

Jagged Arrays

A variation of the multidimensional array is the jagged array: an array of arrays. A jagged array is a single-dimensional array, and each element is itself an array. The element arrays are not required to all be of the same size.

You declare a jagged array like this:

int[][] jaggedArray = new int[3][];

Doing so creates an array of three arrays. These arrays can be initialized like this:

jaggedArray[0] = new int[5];

jaggedArray[1] = new int[4];

jaggedArray[2] = new int[2];