1

这是用于计算完美工作的单词数量的代码。

      st=new StringTokenizer(str);
        while(st.hasMoreTokens())
        {
            String s=st.nextToken();
            count++;
        }

计算字符数的代码是什么?

4

1 回答 1

5

试试这个:

String str = "your string";
int count = str.length( ); 

length()方法返回字符串的长度

于 2013-05-11T10:38:18.063 回答