Java String toLowerCase()
方法有兩種變體。 第一個變數使用給定Locale
的規則將此String
中的所有字元轉換為小寫。 它相當於調用toLowerCase(Locale.getDefault())
。
第二個變體將locale
作為在轉換為小寫時使用的參數。
語法
以下是此方法的語法 -
public String toLowerCase(Locale locale)
參數
- NA
返回值
- 它返回轉換為小寫後的字串。
示例
import java.lang.*;
import java.util.*;
public class Test {
public static void main(String[] args) {
String str1 = "Self Learning Center";
// using the default system Locale
Locale defloc = Locale.getDefault();
// converts all upper case letters in to lower case letters
System.out.println("string value = " + str1.toLowerCase(defloc));
str1 = "WWW.Kaops.COM";
System.out.println("string value = " + str1.toLowerCase(defloc));
}
}
執行上面示例代碼,得到以下結果:
string value = self learning center
string value = www.kaops.com
上一篇:
java中方法重載和方法重寫的區別
下一篇:無