public int getWordNum(String str) {
int num = 0;
boolean flag = false;
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) == ' ') {
flag = false;
} else if (!flag) {
flag = true;
num++;
}
}
return num;
}
标签:false,int,++,单词,获取,flag,num,str,句子
From: https://www.cnblogs.com/HypoPine/p/17046332.html