Syntax for creating a two-dimensional array

前端 未结 12 1204
悲&欢浪女
悲&欢浪女 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:48

    int [][] twoDim = new int [5][5];
    
    int a = (twoDim.length);//5
    int b = (twoDim[0].length);//5
    
    for(int i = 0; i < a; i++){ // 1 2 3 4 5
        for(int j = 0; j 

提交回复
热议问题