显示matrice double int java

时间:2016-11-13 18:54:18

标签: java matrix

我有一个java程序,我在控制台上显示matrice int [] []的结果时出现了一些问题。我的类matrice的代码:

public class Matrix_complexSync {
private int m;
private int n;
private int[][] matrix1;
private int[][] matrix2;
private int[][] matrix3;
private int[][] tempResult;
private int[] counter;

private int firstNoThreads;
private int secondNoThreads;

public Matrix_complexSync(int m, int n) {
    this.m = m;
    this.n = n;
    matrix1 = new int[m][n];
    matrix2 = new int[m][n];
    matrix3 = new int[m][n];
    tempResult = new int[m][n];
    counter = new int[m];
}

public void initialiseMatrix(int maxValue, int firstNoThreads, int secondNoThreads) {
    Random randomGenerator = new Random();
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            matrix1[i][j] = randomGenerator.nextInt(maxValue);
            matrix2[i][j] = randomGenerator.nextInt(maxValue);
            matrix3[i][j] = randomGenerator.nextInt(maxValue);
        }
    }

    this.firstNoThreads = firstNoThreads;
    this.secondNoThreads = secondNoThreads;
}

public int[][] matrixMultiplicationLineThread() throws InterruptedException {
   // my code

    return tempResult;
}
}

和主要:

  public static void main(String[] args) throws  InterruptedException{
    Matrix_complexSync m = new Matrix_complexSync(2,2);
    m.initialiseMatrix(5, 1,1);
    int res[][] = m.matrixMultiplicationLineThread();
    System.out.println("The result is : " + Arrays.toString(res));
}

,控制台告诉我:

  The result is : [[I@5fd0d5ae, [I@2d98a335]

任何想法请以良好的形式展示matrice?

1 个答案:

答案 0 :(得分:0)

   for (int[] row : res)
    {
        System.out.println(Arrays.toString(row));
    }