Java String toUpperCase() 和 toLowerCase() 方法
该方法使用默认语言环境的规则将此String中的所有字符转换为大写 toUpperCase()
该方法使用默认语言环境的规则将此字符串中的所有字符转换为小写。 toLowerCase()
示例
import java.lang.*;
public class StringDemo {
public static void main(String[] args) {
//将所有大写字母转换为小写字母
String str1 = "SELF LEARNING CENTER";
System.out.println("string value = " + str1.toLowerCase());
str1 = "TUTORIALS POINT";
System.out.println("string value = " + str1.toLowerCase());
//将所有小写字母转换为大写字母
String str2 = "This is nhooo";
System.out.println("string value = " + str2.toUpperCase());
str2 = "www.nhooo.com";
System.out.println("string value = " + str2.toUpperCase());
}
}输出结果string value = self learning centre string value = tutorials point string value = THIS IS nhooo string value = WWW.nhooo.COM