MAIN.JAVA:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("Enter the string");
Scanner sc = new Scanner(System.in);
String userInput=sc.nextLine();
String [] listUserInput=userInput.split(" ");
System.out.println("The words in the string are");
for(String i : listUserInput){
System.out.println(i);
}
}
}