-5
我要计算每个句子我写码字的数量,但在句子数字每个字这是我的代码计数句子的单词?
public static void main(String [] args){
Scanner sca = new Scanner(System.in);
System.out.println("Please type some words, then press enter: ");
String sentences= sca.nextLine();
String []count_words= sentences.split(" ");
for(String count : count_words){
System.out.println("number of word is "+count.length());}
}
计数的空格数 “” + 1 – 2017-08-13 21:36:36
欢迎堆栈溢出!请查看我们的[SO问题清单](http://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist)来帮助你提出一个好问题,从而得到一个很好的答案。 –
https://stackoverflow.com/a/5864184/3010171 –