Encodera

Thanks for reading!

Donate to the site — we work hard for you.

Java reference

String.toLowerCase()

Returns a copy of the string with all letters in lower case.

Available since: Java 1.0

Syntax

public String toLowerCase()

Return value

StringA new string in lower case.

Examples

Converting to lower case:

void main() {
    IO.println("Hello, WORLD".toLowerCase());
}

Output:

hello, world

Normalizing input before a comparison:

void main() {
    String command = "  Quit ".strip().toLowerCase();
    IO.println(command.equals("quit"));
}

Output:

true

Notes

Like toUpperCase(), the method depends on the system language; for technical strings use toLowerCase(Locale.ROOT).

See also

Related recipes

In the tutorial

  • String methods — The main String methods in Java: searching, substring, changing case, strip, replace, split, join, repeat and string checks.

Thanks for reading!

Donate to the site — we work hard for you.