Java Scanner Read readMatrix(Scanner in, int n)

Here you can find the source of readMatrix(Scanner in, int n)

Description

read Matrix

License

Open Source License

Declaration

public static int[][] readMatrix(Scanner in, int n) 

Method Source Code

//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;
    }
}

Related

  1. readFileWithoutComments(File input)
  2. readFromReader(Scanner scanner)
  3. readFromScanner(Scanner scanner)
  4. readInt(String prompt)
  5. readLine(String format, Object... args)
  6. readPassword(String format, Object... args)
  7. readPositiveInt(String message, Scanner input)
  8. readSystemInToIntArrayList()
  9. readWholeString(Scanner s)