-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayNew.java
More file actions
35 lines (35 loc) · 968 Bytes
/
ArrayNew.java
File metadata and controls
35 lines (35 loc) · 968 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
33
34
35
// Program: Input and Display 2D Array Elements
// Topic: 2D Arrays
// Description: Reads elements into a 2x2 integer array from user input and then displays them in matrix format.
// Demonstrates basic array traversal using nested loops for two-dimensional arrays.
package Array2D;
import java.util.*;
/**
*
* @author Samim
*/
public class ArrayNew
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int ar[][]=new int[2][2];
System.out.println("Enter The elements :");
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
ar[i][j]=sc.nextInt();
}
}
System.out.println("Array :");
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
System.out.println(ar[i][j]);
System.out.println("");
}
}
}
}