HOW TO PRINT 3*3 MATRIX OF AN 2D ARRAY IN JAVA?
INPUT:-
import java.util.Scanner;
public class example{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n[][]= new int[3][3];
int i,j;
System.out.println("Enter the matrix element ");
for(i=0;i<3;i++){
for(j=0;j<3;j++){
n[i][j]=sc.nextInt();
}
}
System.out.println("Your matrix ");
for(i=0;i<3;i++){
for(j=0;j<3;j++){
System.out.print(" " + n[i][j]);
}
System.out.println();
}
}
}
0 Comments