如果首字符大写,返回true,否则返回false
private boolean isUppercase(String str) {
// TODO Auto-generated method stub
char c = str.charAt(0);
return Character.isUpperCase(c);
}
当然,还可以用
char c = str.charAt(i);
if (!Character.isLowerCase(c))
或者用
char c = s.charAt(0);
if (c >= 'A' && c <= 'Z') {
System.out.println(c + "是大写字母!");
} else if (c >= 'a' && c <= 'z') {
System.out.println(c + "是小写字母!");
} else {
System.out.println(c + "不是一个字母!");
}