Traversing through a sentence word by word
algorithm, java, logic
Solution
Something like this:
String sentence = "Your sentence here.";
String[] words = sentence.split("\\s+"); // splits by whitespace
for (String word : words) {
System.out.println(word);
}
Problem
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.