import java.util.regex.*;
public class TestString {
public static void main(String[] args) {

String s = "AaaaABBBBcc&^%adfsfdCCOOkk99876 _haHA";
int lCount = 0, uCount = 0, oCount = 0;

for(int i=0; i<s.length(); i++) {
char c = s.charAt(i);
if(c >= 'a' && c <= 'z') {
lCount ++;
} else if (c >='A' && c <= 'Z') {
uCount ++;
} else {
oCount ++;
}
}

System.out.println(lCount,uCount,oCount); }
}

解决方案 »

  1.   

    System.out.println("a-z:" + lCount); 
    System.out.println("A-Z:" + uCount);
    System.out.println("others:" + oCount);
      

  2.   

    System.out.println(lCount,uCount,oCount); 
    应该不行吧? 反正我没这样用过 你可以按照1楼那样试下 应该没问题的
      

  3.   

    public class TestString {
    public static void main(String[] args) { String s = "AaaaABBBBcc&^%adfsfdCCOOkk99876 _haHA";
    int lCount = 0, uCount = 0, oCount = 0;

    for(int i=0; i <s.length(); i++) {
    char c = s.charAt(i);
    if(c >= 'a' && c <= 'z') {
    lCount ++;
    } else if (c >='A' && c <= 'Z') {
    uCount ++;
    } else {
    oCount ++;
    }
    }
    System.out.printf("%d,%d,%d",lCount , uCount , oCount);
    }

    这样可以