Problems with array printing

0

Parent 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] = "Feminino";

        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] = "Feminino";
        return matriz;
    }

Method that selects the names of the characters that are Feminine and are in the Arryn family:

public static String imprimeMatrizFeminina(String [] [] mat){
        int cont = 0;
        for(int i=0; i<mat.length; i++){
            if(mat[i][5].equals("Feminino") && mat[i][4].equals("Arryn")) cont ++;
        }
        String[] matrizFemininaArryn = new String [cont];
        for(int i=0; i<mat.length; i++){
            if(mat[i][5].equals("Feminino") && mat[i][4].equals("Arryn")) matrizFemininaArryn[i] = mat[i][0];
            System.out.println("Mulheres da família Arryn:" + Arrays.toString(matrizFemininaArryn));
        }
        return "";
    }

Part of main that calls this method:

case 6:
                String matrizMulheres = imprimeMatrizFeminina(mat);
                System.out.println(matrizMulheres);
                break;

Can anyone tell me why this is happening?

The second impression is correct, but why does the first one occur?

DETAIL: I'm going to have to make an impression for each family in the same method, so I'm not using the return. That is, all the Women, separated by the families.

    
asked by anonymous 17.05.2015 / 21:40

1 answer

1

Solved. It was just moving println out of for

    
17.05.2015 / 21:52