Java: Declaring a multidimensional array without specifying the size of the array ( eg. new int[10][] )

前端 未结 6 1298
忘掉有多难
忘掉有多难 2021-01-13 09:08

I\'ve been trying to figure out what exactly is happening here. I\'m just trying to figure out what the 2 lines are doing that I\'ve commented on below. I found this program

6条回答
  •  南方客
    南方客 (楼主)
    2021-01-13 09:17

    All new int[10][] is declaring is an array of size 10, containing null arrays.

    In the for loop, the null arrays are being instantiated into ever increasing array sizes.

提交回复
热议问题