您可以使用String类的toUpperCase()和 toLowerCase()方法更改大小写 。
public class Sample {
public static void main(String args[]){
String str = "Hello how are you";
String strUpper = str.toUpperCase();
System.out.println("Lower to upper : "+strUpper);
String strLower = str.toLowerCase();
System.out.println("Upper to lower : "+strLower);
}
}输出结果
Lower to upper : HELLO HOW ARE YOU Upper to lower : hello how are you