mardi 26 juillet 2016

if statement returns false but is true??? JAVA ANDROID [duplicate]

This question already has an answer here:

I'm making an Android app but i'm having a problem.

this is a part of my code:

private void declareMessage(String message){
    String[] words;
    words = message.split(" ");
    for (int x = 0; x < words.length; x++){
        Log.e("Error", words[x]);

        String search = "hey";
        String word = words[x].toString();
        if(search == word){
            hey();
        }
    }
}

When I debug the application, I see this in the console:

console

I think that I'm not crazy and that search and word have the same value! But android says: false???

What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire