-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 –