Write a program in java to demonstrate two-dimensional array?

import java.util.Scanner;

class Array2

{

                public static void main(String arg[])

                {

                                Scanner in=new Scanner(System.in);

                                int a[][]=new int[10][10];

                                System.out.println("Enter Row and Column ");

                                int r=in.nextInt();

                                int c=in.nextInt();

                                System.out.println("Enter Input in Matrix ");

                                for(int i=0;i<r;i++)

                                {

                                                for(int j=0;j<c;j++)

                                                                a[i][j]=in.nextInt();

                                }

                                System.out.println("Your Data ");

                                for(int i=0;i<r;i++)

                                {

                                                for(int j=0;j<c;j++)

                                                                System.out.print("\t"+a[i][j]);

                                                System.out.println();

                                }

                }

}

Two Dimensional Array.PNG

, , , , , , , ,

Leave a Reply