1 public class Test {
 2     public static void main(String args[]) {
 3         String s = "aaABDFcddreji$^#^&^%12575hhdshhiJKJLIU";
 4         int lowerCaseCount = 0;
 5         int upperCaseCount = 0;
 6         int unCaseCount = 0;
 7         for(int i = 0; i < s.length(); i++) {
 8             char c = s.charAt(i);
 9             if(c >= 'a' && c <= 'z') {
10                 lowerCaseCount++;
11             }else if(c >= 'A' && c <= 'Z') {
12                 upperCaseCount++;
13             }else {
14                 unCaseCount++;
15             }
16         }
17         System.out.println("小写字母个数为: " + lowerCaseCount);
18         System.out.println("大写字母个数为: " + upperCaseCount);
19         System.out.println("非字母个数为: " + unCaseCount);
20     }
21 }

 

posted on 2018-08-27 10:25  蕾拉  阅读(2141)  评论(0)    收藏  举报