String text = "The Three Pigs";
String[] array = text.split(" ");
EDIT:
If you want to let the user to enter a line of text rather than a single word, then use:
String O = S.nextLine();
instead of:
String O = S.next();
3
solved How do I make a string a string array?