Initialize Values of 2D Array using Nested For Loops
问题 I am trying to format an array that is the following: [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] How could I initialize the two dimensional array and the values using nested for loops? 回答1: I think you have a misunderstanding of two dimensional arrays. Think of them beeing arrays containing arrays. if you really want this: [[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]] You could initialize it like that: int[][] array2d = new int[15][1] for (int i =