开发者社区 问答 正文

【作业】编写程序:计算字符串中出现的单词数

使用Java编写

展开
收起
YDYK 2020-04-24 14:11:46 378 分享 版权
1 条回答
写回答
取消 提交回答
  • Program:
    
      public class Test   
    {  
        public static void main (String args[])  
        {  
            String s = "Sharma is a good player and he is so punctual";  
            String words[] = s.split(" ");  
            System.out.println("The Number of words present in the string are : "+words.length);  
        }  
    }  
    
    2020-04-24 14:12:06
    赞同 展开评论
问答分类:
问答地址: