📜  java 字数统计 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:25.858000             🧑  作者: Mango

代码示例3
String name = "Carmen is a fantastic play"; //arbitrary sentence
        
        int numWords = (name.split("\\s+")).length; //split string based on whitespace
                                                //split returns array - find legth of array
        
        System.out.println(numWords);