Here you can find the source of readMatrix(Scanner in, int n)
public static int[][] readMatrix(Scanner in, int n)
//package com.java2s; //License from project: Open Source License import java.util.Scanner; public class Main { public static int[][] readMatrix(Scanner in, int n) { int[][] matrix = new int[n][n]; for (int i = 0; i < n; i++) { matrix[i] = readArr(in, n);/*from www . ja v a 2 s. c o m*/ } return matrix; } public static int[] readArr(Scanner in, int n) { int[] ar = new int[n]; for (int i = 0; n - i != 0; i++) { ar[i] = in.nextInt(); } return ar; } }