Question: Consider:

```
int[][] multD = new int[5][];
multD[0] = new int[10];

```

Is this how you create a two-dimensional array with 5 rows and 10 columns?

I saw this code online, but the syntax didn't make sense.

Answer: 
Try the following:

```
int[][] multi = new int[5][10];

```

... which is a short hand for something like this:

```
int[][] multi = new int[5][];
multi[0] = new int[10];
multi[1] = new int[10];
multi[2] = new int[10];
multi[3] = new int[10];
multi[4] = new int[10];

```

Note that every element will be initialized to the default value for `int`, `0`, so the above are also equivalent to:

```
int[][] multi = new int[][]{
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};

```
These types of arrays are known as jagged arrays in Java:

```
int[][] multD = new int[3][];
multD[0] = new int[3];
multD[1] = new int[2];
multD[2] = new int[5];

```

In this scenario each row of the array holds the different number of columns. In the above example, the first row will hold three columns, the second row will hold two columns, and the third row holds five columns. You can initialize this array at compile time like below:

```
 int[][] multD = {{2, 4, 1}, {6, 8}, {7, 3, 6, 5, 1}};

```

You can easily iterate all elements in your array:

```
for (int i = 0; i<multD.length; i++) {
    for (int j = 0; j<multD[i].length; j++) {
        System.out.print(multD[i][j] + "\t");
    }
    System.out.println();
}

```