Java program to accept a string and count number of Words Present in it

Java program to accept a string and count number of Words Present in it.(eq- Amar  Singh-- 2)

import java.util.Scanner;

public class demo{

public static void main(String args[]) {

String str = new Scanner(System.in).nextLine();

String []strArr = str.split(" ");

System.out.print(strArr.length);

}

}

Comments