-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray2D.java
More file actions
50 lines (44 loc) · 1.44 KB
/
Copy pathArray2D.java
File metadata and controls
50 lines (44 loc) · 1.44 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package BeginnerJava;
import java.util.Scanner;
public class Array2D {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("2D araay input of A: ");
int[][] A = new int[2][3];
int[][] B = new int[2][3];
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
A[i][j] = input.nextInt();
}
}
System.out.println("2D araay input of A: ");
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
B[i][j] = input.nextInt();
}
}
System.out.println("2D array of A: ");
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
System.out.print(A[i][j] +" ");
}
System.out.println();
}
System.out.print("2D array of B: ");
System.out.println();
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
System.out.print(B[i][j] +" ");
}
System.out.println();
}
// Adding A and B Matrix
System.out.println("Addition of A & B Matrix: ");
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
System.out.print(A[i][j] + B[i][j] + " ");
}
System.out.println();
}
}
}