private void refineWords() {
for(String word : words){
Log.i("word", word);
if (word == "s" || word == "t" || word == "am" || word == "is" || word == "are" || word == "was" || word == "were" || word == "has" ||
word == "have" || word == "been" || word == "will" || word == "be" || word == "would" || word == "should" || word == "shall" ||
word == "must" || word == "can" || word == "could" || word == "the" || word == "as" || word == "it" || word == "they" ||
word == "their" || word == "he" || word == "she" || word == "his" || word == "her" || word == "him" || word == "its" ||
word == "in" || word == "on" || word == "a" || word == "at") {
Log.i("step", "step Success!!");
words.remove(word);
}
}
}
I have a List called “words” and it contains strings. Here the Log.i works for the “word” tag fine but the “step” Statement does not executes. Seems the If condition does not work well. like this method never goes into it although the “words” list contains similar strings. What would be the problem. pleas help..
You need to use
String.equals(), not==.==checks if twoObjectreferences refer to the sameObject:From section 15.21.3 Reference Equality Operators == and != of the Java Language Specification 3.0: