Skip to content

Commit 0510716

Browse files
committed
Create TwoDimensionArr.java
1 parent b581bdf commit 0510716

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.company;
2+
3+
public class TwoDimensionArr {
4+
5+
public static void main(String[] args){
6+
//数据类型 [][] 数组名 = new 数据类型 [整数][整数]
7+
8+
/*
9+
int [][] arr = new int[3][3];
10+
0 1 2
11+
12+
0 12 44 6
13+
14+
1 54 67 88
15+
16+
2 22 56 11
17+
18+
*/
19+
20+
int [][] arr = new int[3][3];
21+
arr[0][0] = 12;
22+
arr[0][1] = 44;
23+
arr[0][2] = 6;
24+
25+
arr[1][0] = 54;
26+
arr[1][1] = 67;
27+
arr[1][2] = 88;
28+
29+
arr[2][0] = 22;
30+
arr[2][1] = 56;
31+
arr[2][2] = 11;
32+
33+
34+
35+
for (int i = 0; i < arr.length; i++){
36+
for (int j = 0; j < arr[i].length; j++)
37+
{
38+
System.out.print(arr[i][j]+"\t");
39+
}
40+
System.out.println();
41+
}
42+
43+
System.out.println();
44+
45+
int array [][] = {{1,2,3},{4,5,6} ,{7,8,9}};
46+
47+
for (int i = 0; i < array.length; i++){
48+
for (int j = 0; j < array[i].length; j++){
49+
System.out.print(array[i][j]+"\t");
50+
}
51+
52+
System.out.println();
53+
}
54+
55+
56+
57+
58+
}
59+
}

0 commit comments

Comments
 (0)