Ragged array is a multi-dimensional array, whose elements has different length:
$ cat Test.java
public class Test {
public static void main(String[] args) {
int[][] aa;
aa = new int[3][]; // notice the unique way of it's initialization
aa[0] = new int[2];
aa[1] = new int[4];
aa[2] = new int[5];
aa[1][3] = 34;
for (int i = 0; i < aa.length; i++) {
for (int j = 0; j < aa[i].length; j++) {
System.out.println("element aa[" + i + "][" + j + "] is: "
+ aa[i][j]);
}
}
}
}
$ javac Test.java
$ java Test
element aa[0][0] is: 0
element aa[0][1] is: 0
element aa[1][0] is: 0
element aa[1][1] is: 0
element aa[1][2] is: 0
element aa[1][3] is: 34
element aa[2][0] is: 0
element aa[2][1] is: 0
element aa[2][2] is: 0
element aa[2][3] is: 0
element aa[2][4] is: 0