我有这样一句话:
I`ve got a Pc
还有一组词:
Hello
world
Pc
dog
如何检查句子是否包含这些单词?在这个例子中,我将与Pc
.
这是我到目前为止得到的:
public class SentenceWordExample {
public static void main(String[] args) {
String sentence = "I`ve got a Pc";
String[] words = { "Hello", "world", "Pc", "dog" };
// I know this does not work, but how to continue from here?
if (line.contains(words) {
System.out.println("Match!");
} else {
System.out.println("No match!");
}
}
}