当比较单词和文本时,java帮助修复true或false条件
我将文本拆分成单词,并希望将其与字符串进行比较,然后如果在文本中找到单词,则将假值返回真值。我的问题是,当使用equals()方法进行检查时,它总是返回false。说信息不在文本中。我该怎么解决这个问题
String test = "Today will go to rainning";
String words = "go";
String[] arrayWords = test.split(" ");
boolean verify = true;
for (int i = 0; i < arrayWords.length; i++)
if (arrayWords[i].equals(words)) {
verify = true;
System.out.println("This word find in text");
break;
} else {
verify = false;
System.out.println("This word not find in text.");
break;
}
}
系统。出来println(“这个词在文本中找不到”)
# 1 楼答案