-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTwoDimentianalArray.java
More file actions
32 lines (22 loc) · 880 Bytes
/
TwoDimentianalArray.java
File metadata and controls
32 lines (22 loc) · 880 Bytes
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
public class TwoDimentianalArray {
public static void main(String[] args) {
int [][] matrix = new int[3][4];
matrix[0][0] = 1; matrix[0][1] = 2; matrix[0][2] = 3; matrix[0][3] = 4;
matrix[1][0] = 5; matrix[1][1] = 6; matrix[1][2] = 7; matrix[1][3] = 8;
matrix[2][0] = 9; matrix[2][1] = 10; matrix[2][2] = 11; matrix[2][3] = 12;
int[][] matrix2 = {{1, 2, 3}, {4, 5, 6}};
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
System.out.print(matrix[i][j] + " ");
}
System.out.println();
}
System.out.println("==========================");
for (int[] i : matrix2) {
for (int j : i) {
System.out.print(j + " ");
}
System.out.println();
}
}
}