Syntax for creating a two-dimensional array

前端 未结 12 1206
悲&欢浪女
悲&欢浪女 2020-11-21 18:11

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?<

12条回答
  •  孤街浪徒
    2020-11-21 18:52

    You can create them just the way others have mentioned. One more point to add: You can even create a skewed two-dimensional array with each row, not necessarily having the same number of collumns, like this:

    int array[][] = new int[3][];
    array[0] = new int[3];
    array[1] = new int[2];
    array[2] = new int[5];
    

提交回复
热议问题