-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTwo_D_Array.java
More file actions
24 lines (22 loc) · 819 Bytes
/
Copy pathTwo_D_Array.java
File metadata and controls
24 lines (22 loc) · 819 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
import java.util.*;
public class Two_D_Array {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the size of the array : ");
int size = sc.nextInt();
int arr[][] = new int[size][size];
System.out.println("Enter the numbers that you want to store : ");
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr.length; j++) {
arr[i][j] = sc.nextInt();
}
}
System.out.println("The elements of the array are : ");
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr.length; j++) {
System.out.print(arr[i][j] + " ");
}
System.out.println();
}
}
}