Java字符串toLowerCase()方法將字符串的所有字符轉換為小寫字母。 toLowerCase()方法有兩種類型。
簽名:
public String toLowerCase(Locale loc) and public String toLowerCase() 參數: loc- locale value to be applied. converts all the characters into lowercase using the rules of given Locale. 返回: returns string in lowercase letter.
// Java program to demonstrate
// working of toLowerCase() method
class Gfg {
public static void main(String args[])
{
String s = "Welcome! to Geeksforgeeks Planet.";
// converting string s to lowercase letter
String gfg1 = s.toLowerCase();
System.out.println(gfg1);
}
}
輸出:
welcome! to geeksforgeeks planet.
// Java program to demonstrate
// working of Locale class in
// toLowerCase() method
import java.util.Locale;
class Gfg {
public static void main(String args[])
{
String s = "I Know YOI Bui You Don't Know ME.";
// Locales with the language "tr" for TURKISH
//"en" for ENGLISH is created
Locale TURKISH = Locale.forLanguageTag("tr");
Locale ENGLISH = Locale.forLanguageTag("en");
// converting string s to lowercase letter
// using TURKISH and ENGLISH language
String gfg2 = s.toLowerCase(TURKISH);
String gfg3 = s.toLowerCase(ENGLISH);
System.out.println(gfg2);
System.out.println(gfg3);
}
}
輸出:
? know yo? bui you don't know me. i know yoi bui you don't know me.
相關用法
- Java String getChars()用法及代碼示例
- Java String concat()用法及代碼示例
- Java String endsWith()用法及代碼示例
- Java String format()用法及代碼示例
- Java String join()用法及代碼示例
- Java Double轉String用法及代碼示例
- Java Byte轉String用法及代碼示例
- Java String toString()用法及代碼示例
- Java Float轉String用法及代碼示例
- Java Short轉String用法及代碼示例
- Java String轉Short用法及代碼示例
- Java String轉Byte用法及代碼示例
- Java String轉Float用法及代碼示例
- Java ZoneOffset of(String)用法及代碼示例
注:本文由純淨天空篩選整理自Niraj_Pandey大神的英文原創作品 Java String toLowerCase() with examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。