Java program for 2D array
import java.util.Scanner;
public class TwoDimArray
{
public static void main(String args[])
{
int a[][]=new int[3][3], i,j;
Scanner s=new Scanner(System.in);
System.out.println("Enter elements of array");
for(i=0; i<3; i++)
{
for(j=0;j<3;j++)
{
a[i][j]=s.nextInt();
}
}
System.out.println("Elements of array are :");
for(i=0; i<3; i++)
{
for(j=0;j<3;j++)
{
System.out.print(a[i][j]+" ");
}
}
}
}
Comments