某个人小朋友的字符串分割统计

方法 有很多种 简要截图 一种 说实在的 我真不知道有什么好说的

String str = "ss w0dm 24hud 5 e6 9";
int count1 = 0;
int count2 = 0;
for (char c: str.toCharArray()){
    if (" ".equals(c)){
        count1++;
    }
    if (0 <= (int)c && c >=9 ){
        count2++;
    }
}
System.out.println("空格:"+count1+"个");
System.out.println("数字"+count2+"个");

原文地址:https://www.cnblogs.com/violet-leaf/p/7766308.html