3 Replies Latest reply: Mar 24, 2008 11:40 AM by 807591 RSS

    Why wont this StringTokenizer usage work?

    807591
      Im making a program to get the average of the number of letters in each word of a string. Heres the code. When I execute it the program never stops... Im totally baffled as to why.. any help?
      import java.util.*;
      public class AlphAv
      {
          public void aver(String s)
          {
              StringTokenizer st = new StringTokenizer(s);
              int total=0, c=0;
              while (st.hasMoreTokens());
              {
                  c++;
                  String A = st.nextToken();
                  total+= A.length();            
              }
              System.out.println("Average: "+((double) (total/c)));
          }
      }