While this is possible to use split to solve it like this one I strongly suggest using more readable way with Pattern
and Matcher
classes. Here is one of examples to solve it:
String string="Hello My Name Is The Mighty Llama";
Pattern p = Pattern.compile("\\S+(\\s\\S+)?");
Matcher m = p.matcher(string);
while (m.find())
System.out.println(m.group());
output:
Hello My
Name Is
The Mighty
Llama