How to print Two-Dimensional Array like table

后端 未结 15 1120
一整个雨季
一整个雨季 2020-11-30 06:55

I\'m having a problem with two dimensional array. I\'m having a display like this:

1 2 3 4 5 6 7 9 10 11 12 13 14 15 16 . . . etc

What basi

15条回答
  •  醉酒成梦
    2020-11-30 07:23

    For traversing through a 2D array, I think the following for loop can be used.
    
            for(int a[]: twoDm)
            {
                System.out.println(Arrays.toString(a));
            }
    if you don't want the commas you can string replace
    if you want this to be performant you should loop through a[] and then print it.
    

提交回复
热议问题