java.lang.String.toUpperCase(Locale locale)方法實例
java.lang.String.toUpperCase(Locale locale) 方法將所有的字符在該字符串使用給定Locale的規則轉爲大寫。
聲明
以下是**java.lang.String.toUpperCase()**方法的聲明
public String toUpperCase()
參數
- locale -- 默認使用的情況下,轉換規則爲這個語言環境。
返回值
此方法返回轉換爲大寫的字符串。
異常
- NA
例子
下面的例子顯示java.lang.String.toUpperCase()方法的使用。
package com.yiibai; import java.lang.*; import java.util.*; public class StringDemo { public static void main(String[] args) { String str1 = "This is YiiBai"; // 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.yiibai.com"; System.out.println("string value = " + str1.toUpperCase(defloc)); } }
讓我們來編譯和運行上面的程序,這將產生以下結果:
string value = THIS IS TUTORIALSPOINT string value = WWW.TUTORIALSPOINT.COM