String API : split() : Illustration (6TH)

 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);
        }
    }
}

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.