1
Main matrix:
public static String [][] matrizPrincipal(){
String [] [] matriz = new String [2] [6];
matriz[0][0] = "Robin Arryn";
matriz[0][1] = "Lino Facioli";
matriz[0][2] = "145";
matriz[0][3] = "Vivo";
matriz[0][4] = "Arryn";
matriz[0][5] = "Masculino";
matriz[1][0] = "Yohn Royce";
matriz[1][1] = "Rupert Vansittart";
matriz[1][2] = "45";
matriz[1][3] = "Vivo";
matriz[1][4] = "Arryn";
matriz[1][5] = "Masculino";
return matriz;
}
I am trying to create a new matrix that stores only the content that is in column 0, that is, in position matriz[i][0]
But I’m not succeeding in the new method. I’m trying to create it like this:
public static String [] [] novaMatriz(String [] [] mat){
String [] [] matriz2 = new String [mat.length] [1];
for(int i=0; i<mat.length; i++){
matriz2[i][0] = mat[i][0];
}
return matriz2;
}
What would be the problem? how to proceed? When I try to call this Return results in that:
[[Ljava.lang.String;@dc0772
String [] [] matriz2 = new String [2] [2];
should not beString [] [] matriz2 = new String [mat.length] [2];
?– Otávio
I think the right thing would be
[mat.length][1]
, because I only need one column to store the names. But the problem persists..– GGirotto