Java 教程
/ Java 如何统计字数
Java 如何统计字数
统计字符串中的字数您可以通过下例轻松地统计字符串中的字数:实例String words = "One Two Three Four";int countWord
统计字符串中的字数
您可以通过下例轻松地统计字符串中的字数:
实例
String words = "One Two Three Four"; int countWords = words.split("\\s").length; System.out.println(countWords);
运行实例 »
点击 "运行实例" 按钮查看在线实例
相关页面
教程:Java 字符串
参考手册:Java 字符串方法