Suppose I have a following code:
int[][] arr = new int[1][1];
arr[0] = new int[2];
This is perfectly fine in Java – why? I assumed it allocates memory for a single-element array that can hold single element-array.
If I can pass an array of arbitrary size to arr[0]
why am I even able to specify the second dimension size?
Is there any use case when
int[][] arr = new int[1][1];
is actually useful over
int[][] arr = new int[1][];