使用正则表达式
String str = "A"
Pattern p = Pattern.compile("[A-Z]+");
Pattern p1 = Pattern.compile("[a-z]+");
Matcher m = p.matcher(str);
Matcher m1 = p1.matcher(str);
if(m.matches){
System.out.println("大写")
//大写转小写
str = str.toLowerCase();
System.out.println(str);
}
if(m1.matches){
System.out.println("小写")
//小写转大写
str = str.toUpperCase();
System.out.println(str);
}