62,614
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) {
String date = (new Date(System.currentTimeMillis())).toString();
String abc="“KWA,fd,fsd,where one-fifth of the world's population in the fastest growing economy in the world has a rapidly growing desire and income to consume healthcare products from around the world”";
String []abcd=abc.split(" |,|,");
int i=0;
for(String s:abcd){
System.out.println("第["+(++i)+"]个单词是:"+s);
System.out.println(++i);
}
System.out.println("总共:"+i+"个单词.");
}
String s = "KWA,where one-fifth of the world's population in the fastest growing economy in the world has a rapidly growing desire and income to consume healthcare products from around the world";
String[] str=(s.split("[\\,| ]"));
System.out.println(str.length);
String str = "KWA,where one-fifth of the world's population in the fastest growing economy in the world has a rapidly growing desire and income to consume healthcare products from around the world";
String []a=str.split(" |,");
for(String sss:a)
{
System.out.println(sss);
}
System.out.println(a.length);
String str = "KWA, where one-fifth of the world's population in the fastest growing economy in the world has a rapidly growing desire and income to consume healthcare products from around the world";
System.out.println(str.split("[, ]+").length);
String textString = "KWA,where one-fifth of the world's population in the fastest growing economy in the world has a rapidly growing desire and income to consume healthcare products from around the world";
String tempString = textString.replaceAll(" ", "");
int wordNum = (textString.length - tempString.length) + 1;