public static void main(String[] args) {
String str = "AFkf679afKAJKsf9uj=-`1lksSFf/.,p';l";
String wordAndNumber = str.replaceAll("\\W", "");
String word = wordAndNumber.replaceAll("\\d", "");
Integer upCount = word.replaceAll("[a-z]", "").length();
Integer lowCount = word.replaceAll("[A-Z]", "").length();
String number = wordAndNumber.replaceAll("[a-zA-Z]", "");
String other = str.replaceAll("\\w", "");
System.out.println("大写字母为:" + upCount + "个");
System.out.println("小写字母为:" + lowCount + "个");
System.out.println("阿拉伯数字个数为:" + number.length() + "个");
System.out.println("其他字符个数为:" + other.length() + "个");
}
string类型的方法可以用正则。