我试图将单个字符标识为大写或小写字母。我对if else语句的逻辑有困难。任何帮助将非常感激。当它运行时,它现在将打印它是大写还是小写。
String x = "";
if (Character.isLetter(x)) {
System.out.println(x + " is a letter.");
}
else if (Character.isUpperCase(x)) {
System.out.println(x + " is upper case.");
}
else if (Character.isLowerCase(x)) {
System.out.println(x + " is lower case.");
}
答案 0 :(得分:1)
试试这个......
if (Character.isLetter(x)) {
System.out.println(x + " is a letter.");
if (Character.isUpperCase(x)) {
System.out.println(x + " is upper case.");
}
else if (Character.isLowerCase(x)) {
System.out.println(x + " is lower case.");
}
}