2016-11-13 8 views
0

私はjavaでプログラムを持っていますが、コンソールにmatrice int [] []の結果を表示する際にいくつかの問題があります。matrice double int java

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

とメイン::私のクラスMATRICEのコード

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 : [[[email protected], [[email protected]] 

すべてのアイデアは良い形でMATRICEを表示するようにしてください?

+1

ループして各値を印刷しますか? – UnholySheep

答えて

0
for (int[] row : res) 
    { 
     System.out.println(Arrays.toString(row)); 
    } 
関連する問題