package com.example.phone.controller; public class test6 { public static void main(String[] args) { String str="agnjgALKGj24249gajl134我爱你新新5398gjAKg我爱你"; int a=0; int b=0; int c=0; for (int i=0;i<str.length();i++){ char d=str.charAt(i); if (d >= '0'&& d<= '9'){ a++; }else if (d >= 'a'&& d<= 'z'||d >= 'A'&&d <= 'Z'){ b++; }else { c++; } } System.out.println("数字:"+a+"字母:"+b+"中文:"+c); } }
java实现统计字符串中数字中文字母各自总数
最新推荐文章于 2023-02-25 14:27:16 发布