Java.lang.String.toUpperCase() 方法
描述
java.lang.String.toUpperCase(Locale locale) 方法使用给定语言环境的规则将此字符串中的所有字符转换为大写。
声明
以下是 java.lang.String.toUpperCase() 方法的声明。
public String toUpperCase()
参数
locale − 使用此语言环境的大小写转换规则。
返回值
此方法返回字符串,转换为大写。
异常
NA
示例
下面的例子展示了 java.lang.String.toUpperCase() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
import java.util.*;
public class StringDemo {
public static void main(String[] args) {
String str1 = "This is TutorialsPoint";
// using the default system Locale
Locale defloc = Locale.getDefault();
// converts all lower case letters in to upper case letters
System.out.println("string value = " + str1.toUpperCase(defloc));
str1 = "www.tutorialspoint.com";
System.out.println("string value = " + str1.toUpperCase(defloc));
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
string value = THIS IS TUTORIALSPOINT string value = WWW.TUTORIALSPOINT.COM

