实例 Java 使用方法将字符串转换为大写和小写

x
 
public class Main {
  public static void main(String[] args) {
    String txt = "Hello World";
    System.out.println(txt.toUpperCase());
    System.out.println(txt.toLowerCase());
  }
}
                    

输出结果

HELLO WORLD
hello world