Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Java

String.toLowerCase — converting to lowercase

String.toLowerCase returns lowercase text. The choice of Locale affects the result; use Locale.ROOT for language-independent text.

Version: Java SE 21; repository runtime, production runtime not attested

Syntax

public String toLowerCase()
public String toLowerCase(Locale locale)

String.toLowerCase returns lowercase text without modifying the original String. Keep the returned value if you need to use it later.

toLowerCase() uses Locale.getDefault(). The overload toLowerCase(Locale locale) applies explicitly selected rules. Choose Locale.ROOT for language-independent text; for natural-language text, choose the appropriate locale.

Unicode rules do not always map one char to one char, so the result's length can change. The example demonstrates the difference between Locale.ROOT and a Turkish Locale, and that the original remains unchanged.

Examples

import java.util.Locale;

public class Main {
    public static void main(String[] args) {
        String text = "TITLE";
        System.out.println(text.toLowerCase(Locale.ROOT));
        System.out.println(text.toLowerCase(Locale.forLanguageTag("tr")));
        System.out.println(text);
    }
}

Result

title
tıtle
TITLE

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources