w3resource

Java String: toLowerCase() Method

public String toLowerCase()

The toLowerCase() method converts all of the characters in this String to lower case using the rules of the default locale. This is equivalent to calling toLowerCase(Locale.getDefault()).

Note: This method is locale sensitive, and may produce unexpected results if used for strings that are intended to be interpreted locale independently. Examples are programming language identifiers, protocol keys, and HTML tags. For instance, "TITLE".toLowerCase() in a Turkish locale returns "t\u0131tle", where '\u0131' is the LATIN SMALL LETTER DOTLESS I character. To obtain correct results for locale insensitive strings, use toLowerCase(Locale.ROOT).

Java Platform: Java SE 8

Syntax:

toLowerCase()

Return Value: the String, converted to lowercase.

Return Value Type: String

Pictorial presentation of Java String toLowerCase() Method

Java String: toLowerCase() Method

Example: Java String toLowerCase(Locale locale) Method

The following example shows the usage of java String() method.

public class Example {
       public static void main(String[] args)
    {
        String str = "The Quick BroWn FoX JuMps oVer tHE laZy Dog!";

        // Convert the above string to all lowercase.
        String lowerStr = str.toLowerCase();
        System.out.println();
        // Display the two strings for comparison.
        System.out.println("Original String: " + str);
        System.out.println("String in lowercase: " + lowerStr);
        System.out.println();
    }
}

Output:

Original String: The Quick BroWn FoX JuMps oVer tHE laZy Dog!                                                 
String in lowercase: the quick brown fox jumps over the lazy dog!

Java Code Editor:

Previous:toCharArray Method
Next:toString Method



Follow us on Facebook and Twitter for latest update.