如何在句子“hi,how are you?”中解析单词“hi”或在“how are you?”中解析单词“how”?
以下是所需代码示例:
String word = "hi";
String word2 = "how";
Scanner scan = new Scanner(System.in).useDelimiter("\n");
String s = scan.nextLine();
if(s.equals(word)) {
System.out.println("Hey");
}
if(s.equals(word2)) {
System.out.println("Hey");
}