Tuesday, August 11, 2015

Print a Matrix

The below code helps to print a matrix in a formatted way, so you can easily visualize what's happening while working with matrices.

 public void printMatrix(int[][] output)
 {
  for(int i=0; i< output.length; i++)
  {
   for(int j=0; j< output[i].length; j++)
   {
    System.out.print(output[i][j]);
    System.out.print(" ");
   }
   System.out.println(" ");
  }
 }

No comments:

Post a Comment