Good morning guys, I'm a beginner in Java and I have a problem here. Can someone tell me what these strange characters appear in the console when executing a matrix sum method (I'm using Threads)?
Matrixsummethod:
publicclasssomaMatriz{publicint[][]matriz(int[][]m1,int[][]m2){intsize=m1.length;int[][]c=newint[size][size];RunnablethreadMatriz1=newRunnable(){publicvoidrun(){try{for(inti=0;i<size;++i){for(intj=0;j<size;++j){//\ttemfunçãodetabulação//\ntemfunçãodequebralinhac[i][j]=m1[i][j]+m2[i][j];System.out.printf("%d\t",c[i][j]);
}
System.out.printf("\n");
}
Thread.sleep(1000); //Para demorar um segundo
} catch (InterruptedException e) {
System.out.println("A Thread sofreu uma interrupcao!");
}
}
};
Thread th1 = new Thread(threadMatriz1);
th1.start();
return c;
}
}
Main to call the Matrix method:
package trabSD23;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
int [][] ar1 = { {1,2,3}, {4,5,6}, {6,8,2} };
int [][] ar2 = { {9,6,6}, {6,8,3}, {3,4,7} };
int [][] ar3 = { {7,2,5}, {1,4,2}, {6,8,6} };
somaMatriz teste = new somaMatriz();
for (int i = 0; i < 10; i++) {
System.out.println(teste.matriz(ar1, ar2));
System.out.println(teste.matriz(ar2, ar3));
}
}
}