Here, the task is to declare a two dimensional array – where number rows are given and columns are variable length:
To declare such array, we use the following syntax:
int[][] jag = new int[3][];
To assign rows values with variable length, we use following syntax:
jag[0] = new int[] { 12, 34, 5, 6, 7 };
jag[1] = new int[] { 15, 52 };
jag[2] = new int[] { 1, 2, 3 };
Program:
Output