This question already has an answer here:
- How do I compare strings in Java? 23 answers
I'm simply sending lines using socket, and trying to stop printing messages when the line is "terminate". But, instead, when text = "terminate" it simply prints it and does not break!! Thanks in advance :)
Here is the condition code:
String text = null;
while (true) {
//Reading data received from the socket
text = input.readLine();
if (text == null || text == "terminate") {
break;
}
Aucun commentaire:
Enregistrer un commentaire