Here you can find the source of printMatrix(int[][] matrix)
public static void printMatrix(int[][] matrix)
//package com.java2s; //License from project: Open Source License public class Main { public static void printMatrix(int[][] matrix) { for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[i].length; j++) { if (matrix[i][j] < 10 && matrix[i][j] > -10) { System.out.print(" "); }//www . j av a 2 s . com if (matrix[i][j] < 100 && matrix[i][j] > -100) { System.out.print(" "); } if (matrix[i][j] >= 0) { System.out.print(" "); } System.out.print(" " + matrix[i][j]); } System.out.println(); } } public static void printMatrix(boolean[][] matrix) { for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[i].length; j++) { if (matrix[i][j]) { System.out.print("1"); } else { System.out.print("0"); } } System.out.println(); } } public static void printMatrix(char[][] matrix) { for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[i].length; j++) { System.out.print(matrix[i][j]); } System.out.println(); } } }