.toLowerCase()

MFValmayor's avatar
Published Feb 22, 2023
Contribute to Docs

The .toLowerCase() method converts all the characters of a string to lowercase characters in Java.

Note: This method is locale sensitive, in consequence it might produce unexpected results because it takes into account the user’s locale, particularly when the string represents locale-specific values, e.g. date or time.

Syntax

upperCaseString.toLowerCase();

Where upperCaseString is the string with some or all upper case characters to be converted.

Example

This example converts uppercase characters to lowercase characters:

// Example.java
public class Example {
public static void main(String[] args){
String S1 = new String("ThiS IS an EXAMple");
System.out.println(S1.toLowerCase());
}
}

This outputs the following:

this is an example

All contributors

Contribute to Docs

Learn Java on Codecademy