HOW TO SUM HORIZONTAL IN 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,sum[]= new int[3];

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

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

  for(i=0;i<3;i++){
  System.out.print("\t" + sum[i]);
}
}
}

OUTPUT:-