逐字遍历一个句子

Sun*_*ngh 2 java algorithm logic

如何逐字遍历任何给定的句子?java中有内置函数吗?我不知道如何开始。

jlo*_*rdo 7

像这样的东西:

String sentence = "Your sentence here.";
String[] words = sentence.split("\\s+"); // splits by whitespace
for (String word : words) {
    System.out.println(word);
}
Run Code Online (Sandbox Code Playgroud)