vendredi 30 septembre 2016

Why my if statement ignoring string condition in java? [duplicate]

This question already has an answer here:

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