Here you can find the source of printMatrix(Object[][] matrix)
Parameter | Description |
---|---|
matrix | a parameter |
public static void printMatrix(Object[][] matrix)
//package com.java2s; /**//from w ww. j a va 2 s . co m * <p> * This software is distributed under the <a href="http://hci.stanford.edu/research/copyright.txt"> * BSD License</a>. * </p> * * @author <a href="http://graphics.stanford.edu/~ronyeh">Ron B Yeh</a> (ronyeh(AT)cs.stanford.edu) */ public class Main { /** * Displays a matrix of Objects. * * @param matrix */ public static void printMatrix(Object[][] matrix) { int numRows = matrix[0].length; int numCols = matrix.length; System.out.println("Matrix of " + matrix[0][0].getClass().getSimpleName() + ": ["); for (int y = 0; y < numRows; y++) { System.out.print(" row " + y + ": ["); for (int x = 0; x < numCols; x++) { System.out.print(matrix[x][y]); if (x != numCols - 1) { System.out.print(", "); } } System.out.println("]"); } System.out.println("]"); } }