逐字遍历一个句子 [英] Traversing through a sentence word by word
本文介绍了逐字遍历一个句子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何逐字遍历任何给定的句子? Java中是否有任何内置函数?我不知道如何开始.
How is it possible to traverse through any given sentence word by word? Is there any in-built functions in java? I have no idea how to begin.
推荐答案
类似以下内容:
String sentence = "Your sentence here.";
String[] words = sentence.split("\\s+"); // splits by whitespace
for (String word : words) {
System.out.println(word);
}
这篇关于逐字遍历一个句子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文