ellesehc

Word Counter

Nov 16th, 2015
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1. package Trial;
  2. public class Trial1
  3. {
  4.         public static void main(String[] args)
  5.         {
  6.                String essay = "words words words";
  7.                int count = 0;
  8.                for(int x = 0; x < essay.length(); x++)
  9.                {
  10.                    if(essay.charAt(x) == ' ')
  11.                    {
  12.                        count++;
  13.                    }
  14.                }
  15.                
  16.                System.out.println(count);
  17.         }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment