Advertisement
Masovski

[Java Basics][Collections-HW] 05. Count All Words

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