I created an array and put it to initialize with the values passed in the constructor, but it is not initializing. I created the object, I threw the values, but when I call the method to show the matrix, it does not appear, as if it had not been created. Can someone help me?
import java.util.Scanner;
public class ExerMatriz {
Scanner s = new Scanner(System.in);
private int linha;
private int coluna;
ExerMatriz(){
System.out.println("Digite a quantidade de linhas");
this.setLinha(s.nextInt());
System.out.println("Digite a quantidade de colunas");
this.setColuna(s.nextInt());
}
private int m[][] = new int[this.getLinha()][this.getColuna()];
public void mostrarMatriz(){
for(int i=0; i< m.length;i++){
for(int j=0; j<m[0].length;j++){
System.out.print(this.m[i][j]);
}
System.out.println();
}
}
public int[][] getM() {
return m;
}
public void setM(int[][] m) {
this.m = m;
}
public int getLinha() {
return linha;
}
public void setLinha(int linha) {
this.linha = linha;
}
public int getColuna() {
return coluna;
}
public void setColuna(int coluna) {
this.coluna = coluna;
}
}