3 Replies Latest reply on Mar 24, 2008 4:40 PM by 807591

    Why wont this StringTokenizer usage work?

      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());
                  String A = st.nextToken();
                  total+= A.length();            
              System.out.println("Average: "+((double) (total/c)));