Adiiia Adiiia - 1 year ago 107
Java Question

displaying matrice double int java

I have a program in java and I got some problems with displaying on the console a result of a matrice int[] []. My code for the class 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;

and the main:

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

and the console shows me:

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

Any ideas please to display the matrice in the good form?

Answer Source
   for (int[] row : res)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download