Java String toLowerCase()(String转小写)与示例

作者: Arvin Chen 分类: Java 来源: Break易站(www.breakyizhan.com)
  •   Java 字符串

     Java String toLowerCase()(String转小写)与示例

    Java字符串toLowerCase()方法中的字符串的所有字符转换为小写字母。有两种类型的toLowerCase()方法。

    签名:

    public String toLowerCase(Locale loc)
    和
    public String toLowerCase() 
    参数:
    loc - 要应用的语言环境值。将所有字符转换为
    小写使用给定语言环境的规则。  
    返回:以小写字母返回字符串。
    
    // 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 字符串
  •   本文标题:Java String toLowerCase()(String转小写)与示例 - Break易站
    转载请保留页面地址:https://www.breakyizhan.com/java/3995.html

    发表笔记

    电子邮件地址不会被公开。 必填项已用*标注

    更多阅读