jeudi 24 mai 2018

Java strange evaluation of string compare in if-statement [duplicate]

This question already has an answer here:

while testing Java/Android app in Android Studio I got unexpected behaviour. So I stepped through and found this strange "if" evaluation (see this debugger screenshot ).

It seems to evaluate ("123" == "123") to false...???

The "UserName" parameter is the content of an EditText control. The function "Login" is called here:

    clsNAV.Login(EdUser.getText().toString(), EdPassword.getText().toString(),
                    new clsNAV.cbkLoginResult() { (...)

Of course I did not enter any invisible characters to the EditText (at least not knowingly).

Aucun commentaire:

Enregistrer un commentaire