Advertisement
DNNdrago

5. Count All Words

May 23rd, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.24 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class _05_CountAllWords {
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner sc = new Scanner(System.in);
  8.         String sentence = sc.nextLine();
  9.         System.out.println(sentence.split("\\W+").length);
  10.     }
  11.  
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement