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, worldNormalizing input before a comparison:
void main() {
String command = " Quit ".strip().toLowerCase();
IO.println(command.equals("quit"));
}Output:
trueNotes
Like toUpperCase(), the method depends on the system language; for technical strings use toLowerCase(Locale.ROOT).
See also
- String.toUpperCase() — Returns a copy of the string with all letters in upper case.
- String.equalsIgnoreCase() — Compares two strings ignoring letter case.
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.