2
I’m trying to make a line break in a Array
, but I am not succeeding in trying to execute the split()
, summarizing, I want to make a table of 10 rows with 2 columns that acquire 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 regarding the exclusion of a line and draw by results placed by first.
What is the content of
resultados
andresultados2
? Are you sure to give atoString
in an array will do what you want? And also, your question is not very clear, try edit it and add more details.– Jéf Bueno
resultados
andresultados2
receive the values of twoArrayLists
, tolist
andlist2
, thatArray
that I want to create needs to beString
to be read by the client, because that’s how I created the client reading part, but that’s not the case, I was trying to do something likeString[][] res = new String[10][2];
 res[0][0] = resultados;
 res[0][1] = resultados2;
, but gives the error[[Ljava.lang.String; cannot be cast to java.lang.String
– Matheus Lopes
Okay, let’s go in pieces. Make a
System.out.println(resultados);
andSystem.out.println(resultados2);
and see on the console which the contents of these two variables.– Jéf Bueno
The result is correct, is pulling the variables of the
list
andlist2
correctly– Matheus Lopes
But I need to see the contents of them in order to help you. Another thing, in the comment above you say that you are receiving an error, in your question you say nothing about error. Put the error in the question so that other people can see clearly and help you.
– Jéf Bueno
Okay, I’ll explain the purpose of my program to make it clearer, I have a client who gets the information and the server, this server launches a random number and the client "kicks" values until right, at the end I need to show a table that informs the random number that the server has launched and the number of attempts, here comes the
resultado
(attempts) andresultado2
(random number) the content comes out like this[tentativas, numRan, tentativas, numRan...]
I need you to stay[ten, numRan]
there on the bottom line the same thing[ten, numRan]
in the case of 10 rows per 2 columns– Matheus Lopes