HOW TO SUM OF TWO MATRIX 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 k[][]= new int[3][3];
int i,j,sum[][]= new int[3][3];


System.out.println("Enter your first matrix : ");
 for(i=0;i<3;i++){
   for(j=0;j<3;j++){

   n[i][j]=sc.nextInt();
}
}

System.out.println("Your first matrix : ");
for(i=0;i<3;i++){
  for(j=0;j<3;j++){
  System.out.print(" " + n[i][j]);
}
 System.out.println();
}


System.out.println("Enter your second matrix : ");
 for(i=0;i<3;i++){
   for(j=0;j<3;j++){
  k[i][j]=sc.nextInt();

}
}


System.out.println("Your Second matrix : ");
for(i=0;i<3;i++){
  for(j=0;j<3;j++){
  System.out.print(" " + k[i][j]);
}
 System.out.println();
}

System.out.println("Your sum matrix :  ");
 for(i=0;i<3;i++){
  for(j=0;j<3;j++){
  sum[i][j]=n[i][j]+k[i][j];

 System.out.print(" " + sum[i][j]);
}

   System.out.println(" " );
}
}
}

OUTPUT:-