的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 = "nhooo.com"; 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 = nhooo.com string value = THIS IS nhooo string value = WWW.nhooo.COM