直接上代码:
public class ArrayTest09 {
public static void main(String[] args) {
int[][] a = new int[3][4];
int[][] a1 = {
{1,2,3,4},
{45,25,1,3},
{4,5,8,9},
};
printArray(a1);
System.out.println("===============================");
printArray(new int[][]{{1,2,3,4},{45,25,1,3},{4,5,8,9}});
}
public static void printArray(int[][] array){
for(int i = 0;i<array.length;i++){
for(int j = 0;j<array[i].length;j++){
System.out.print(array[i][j] + " ");
}
System.out.println();
}
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
运行结果:
