String toUpperCase()
描述 (Description)
java.lang.String.toUpperCase()方法使用默认语言环境的规则将此String中的所有字符转换为大写。
声明 (Declaration)
以下是java.lang.String.toUpperCase()方法的声明
public String toUpperCase()
参数 (Parameters)
NA
返回值 (Return Value)
此方法返回String,转换为大写。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.lang.String.toUpperCase()方法的用法。
package com.iowiki;
import java.lang.*;
public class StringDemo {
public static void main(String[] args) {
// converts all lower case letters in to upper case letters
String str1 = "This is IoWiki";
System.out.println("string value = " + str1.toUpperCase());
str1 = "www.iowiki.com";
System.out.println("string value = " + str1.toUpperCase());
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
string value = THIS IS IOWIKI
string value = WWW.iowiki.com