This question already has an answer here:
- How do I compare strings in Java? 23 answers
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:
I think that I'm not crazy and that search and word have the same value! But android says:
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire