Java word count program

后端 未结 22 1516
北荒
北荒 2020-12-09 06:48

I am trying to make a program on word count which I have partially made and it is giving the correct result but the moment I enter space or more than one space in the string

22条回答
  •  情深已故
    2020-12-09 07:27

    you should make your code more generic by considering other word separators as well.. such as "," ";" etc.

    public class WordCounter{
        public int count(String input){
            int count =0;
            boolean incrementCounter = false;
            for (int i=0; i= 'A' && c<='Z') || (c >= 'a' && c<='z'); 
        }
    }
    

提交回复
热议问题