public class JiLuzimucishu { public static void main(String[] args) { String str = "dsaw e3 242 123"; //定义字符 count(str); //引用count方法 } public static void count(String str) { //定义count方法 if (str == null) { //非空验证 System.out.println("输入不能为 null"); return; } int strLen = str.length(); int lowCount = 0; //定义记录变量 int uperCount = 0; int otherCount = 0; int numCount = 0; for (int i = 0; i < strLen; i++) { if (str.charAt(i) >= '0' && str.charAt(i) <= '9') {//0-9之间 numCount++; } else if (str.charAt(i) >= 'a' && str.charAt(i) <= 'z') {//a-z lowCount++; } else if (str.charAt(i) >= 'A' &
String基础练习之字母计数器
最新推荐文章于 2024-07-20 22:33:40 发布
public class JiLuzimucishu { public static void main(String[] args) { String str = "dsaw e3 242 123"; //定义字符 count(str); //引用count方法 } public static void count(String str) { //定义count方法 if (str ..
摘要由CSDN通过智能技术生成