Wrapping text

2

I'm trying to do a line break in a Array , however I'm not having success trying to run split() , in short, I want to make a table of 10 rows with 2 columns that get the values of list and list2

public class Ultimos10 {

    public Ultimos10(ObjectOutputStream saida, Socket cliente) throws IOException {
        String resultados = NovoJogo.list.toString(); //Puxa Array da outra classe
        String resultados2 = NovoJogo.list2.toString();

        String quebra[]=resultados.split("\n"); //Tentando colocar split
        String quebra2[]=resultados2.split("\n");

        for(String resul:quebra){ //Imprime na tela do cliente
            saida.writeObject(resul+"\r\n");
        }

        for(String resul2:quebra){
            saida.writeObject(resul2);
        }

        Servidor serv = new Servidor();
        serv.Menu(cliente);
    }
}

I also have doubts about deleting a line and raffle by results placed first.

    
asked by anonymous 20.09.2015 / 17:06

2 answers

3

I no longer have the code, but I remember doing it in the following way:

String variavel = System.getProperty("line.separator");

when i wanted to break the line i pulled the variable

    
03.12.2015 / 11:33
1

If both arrays have the same size (attempts) (random), then you can simplify your method:

String attempts [] = ... // Your array of attempts     String numeroRamdomico [] = ... // Your random number array

for (int i = 0; i < tentativas.length; i++) {
   System.out.println("Tentativa: " + tentativas[i] 
                    + " | Numero Randomico: " + numeroRamdomico[i]);
}

In this way you are generating your list with two columns and if you want to limit the number of rows, just put tentativas.length the value you want.

    
21.09.2015 / 03:47